create account

Python Help: what database should I use for sending Lightning Streaming Sats into Hive for Podcasting 2.0? by brianoflondon

View this thread on: hive.blogpeakd.comecency.com
· @brianoflondon · (edited)
$5.15
Python Help: what database should I use for sending Lightning Streaming Sats into Hive for Podcasting 2.0?
UPDATE: I'm using MongoDB along with the Motor Python library for async connections. It's proving to be .... interesting. But it does seem to be working.

I'm working on something cool.... a limited Lightning Network to Hive bridge for podcasters on 3speak.
<div class="pull-right">


![Streaming Sats raw data](https://files.peakd.com/file/peakd-hive/brianoflondon/23t76kVtD5n2RntjPpgWipvUKRRRcm4Z7tqXEVPZ5XkptmJHmKPqK1XPGCv9tF4tmp7MU.png)

</div>

As I alluded to but didn't fully explain last week, every show on @threespeak is becoming a podcast because 3speak are adding RSS feeds to all their channels. It was a relatively simple code change with a huge implication. I'll explore that in a post very soon.

## The programming question

What I need help with is a modern database way, fully containerised to run alongside another containerised Python script I'm writing which reads the incoming invoices off my own Lightning node.

I'm bewildered by the choices of MongoDB, Postgres, MySQL and even wondering if MySQLLite is enough for what I'm doing! I suspect I'll use Tortoise ORM alongside the FastAPI I'm using so far.

My code is fetching and building a Python Dict object with the details of each `keysend` invoice and this is what I need to store in the database.

I already have a basic model in Pydantic so what's the best database to store these two datastructures?

```
class V4VDetails(BaseModel):
    action: Optional[str]
    app_name: Optional[str]
    podcast: Optional[str]
    name: Optional[str]
    url: Optional[str]
    itemID: Optional[int]
    episode_guid: Optional[str]
    episode: Optional[str]
    ts: Optional[int]
    speed: Optional[float]
    feedID: Optional[int]
    action: Optional[str]
    message: Any
    hive_accname: Optional[str]
```
and
```
class V4VItem(BaseModel):
    r_hash: str
    add_index: int
    value: int
    settle_date: int
    utc_datetime: datetime = None
    localtime: datetime = None
    details: V4VDetails
```

# The Background

For now I'm working on one very specific aspect. These new Podcasting 2.0 Certified RSS feeds which @threespeak generates include what is called a "Value Block". This looks like:

```
<podcast:value type="lightning" method="keysend" suggested="0.00000050000">
  <podcast:valueRecipient name="brianoflondon via 3Speak" address="0396693dee59afd67f178af392990d907d3a9679fa7ce00e806b8e373ff6b70bd8" type="node" split="99"></podcast:valueRecipient>
  <podcast:valueRecipient name="PodcastIndex" address="03ae9f91a0cb8ff43840e3c322c4c61f019d8c1c3cea15a25cfc425ac605e61a4a" type="node" fee="True" split="1"></podcast:valueRecipient>
</podcast:value>
```

When someone listens to a podcast with a block like that in the RSS on one of the new [streaming sats enabled Podcasting 2.0 apps from newpodcastapps.com](http://newpodcastapps.com/) they can automatically send a small payment to the creator via the Lightning network. They can also send boosts and now messages too.

One day, perhaps, we'll have Hive as a native option in the system but for now the main dev effort has gone into the Lightning network. Unfortunately receiving Lightning is a non trivial option as it generally involves having a node on the Bitcoin network running 24/7. 

So for now one Lightning Node is going to receive payments on behalf of 3speak video creators and forward those as Hive transfers along with any messages or notes that come in.


----

![brianoflondon hive footer.png](https://files.peakd.com/file/peakd-hive/brianoflondon/fIN9elzs-brianoflondon20hive20footer.png)

- [Vote for APSHamilton's Witness KeyChain or HiveSigner](https://vote.hive.uno/@apshamilton)
- [Vote for APSHamilton's Witness direct with HiveSigner](https://hivesigner.com/sign/account-witness-vote?witness=apshamilton&approve=1)
- [Get Brave](https://brave.com/bri740)
- [Use my referral link for crypto.com](https://platinum.crypto.com/r/wkva2kezch) to sign up and we both get $25 USD
- [Sign up for BlockFi](https://blockfi.com/?ref=96f858b3)
- [Find my videos on 3speak](https://3speak.online/user/brianoflondon)
- [Join the JPBLiberty Class Action law suit](https://jpbliberty.formstack.com/forms/class_member_signup?Referral=brianoflondon)
- [Verify my ID and Send me a direct message on Keybase](https://keybase.io/brianoflondon)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 21 others
properties (23)
authorbrianoflondon
permlinkpython-help-what-database-should-i-use-for-sending-lightning-streaming-sats-into-hive-for-podcasting-20
categoryprogramming
json_metadata"{"app":"peakd/2021.07.2","format":"markdown","description":"I'm building the Lightning to Hive bridge for Podcasting 2.0 Streaming Sats","tags":["programming","development","podcasting2","podping","leofinance","palnet","python"],"users":["threespeak","apshamilton"],"image":["https://files.peakd.com/file/peakd-hive/brianoflondon/23t76kVtD5n2RntjPpgWipvUKRRRcm4Z7tqXEVPZ5XkptmJHmKPqK1XPGCv9tF4tmp7MU.png","https://files.peakd.com/file/peakd-hive/brianoflondon/fIN9elzs-brianoflondon20hive20footer.png"]}"
created2021-07-22 08:30:00
last_update2021-07-27 16:28:33
depth0
children3
last_payout2021-07-29 08:30:00
cashout_time1969-12-31 23:59:59
total_payout_value2.554 HBD
curator_payout_value2.593 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,291
author_reputation708,996,430,016,291
root_title"Python Help: what database should I use for sending Lightning Streaming Sats into Hive for Podcasting 2.0?"
beneficiaries
0.
accounthive-169321
weight200
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id105,061,349
net_rshares9,740,000,602,775
author_curate_reward""
vote details (85)
@coininstant · (edited)
$1.13
Yeah I'd try MySQLLite first, should be easier because it's an embedded database which means the DB engine runs as a part of the app. I think that would work better for your setups. Start simple and work your way up.  
👍  , ,
properties (23)
authorcoininstant
permlinkre-brianoflondon-qwn286
categoryprogramming
json_metadata{"tags":["programming"],"app":"peakd/2021.07.2"}
created2021-07-22 08:57:42
last_update2021-07-22 08:59:21
depth1
children0
last_payout2021-07-29 08:57:42
cashout_time1969-12-31 23:59:59
total_payout_value0.567 HBD
curator_payout_value0.567 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length218
author_reputation85,005,233,645,036
root_title"Python Help: what database should I use for sending Lightning Streaming Sats into Hive for Podcasting 2.0?"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id105,061,588
net_rshares2,117,844,665,701
author_curate_reward""
vote details (3)
@hivebuzz ·
Congratulations @brianoflondon! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

<table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@brianoflondon/upvotes.png?202107241301"></td><td>You distributed more than 67000 upvotes.<br>Your next target is to reach 68000 upvotes.</td></tr>
</table>

<sub>_You can view your badges on [your board](https://hivebuzz.me/@brianoflondon) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>

properties (22)
authorhivebuzz
permlinkhivebuzz-notify-brianoflondon-20210724t132341000z
categoryprogramming
json_metadata{"image":["http://hivebuzz.me/notify.t6.png"]}
created2021-07-24 13:23:39
last_update2021-07-24 13:23:39
depth1
children0
last_payout2021-07-31 13:23:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length649
author_reputation368,402,736,822,151
root_title"Python Help: what database should I use for sending Lightning Streaming Sats into Hive for Podcasting 2.0?"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id105,099,461
net_rshares0
@hivebuzz ·
Congratulations @brianoflondon! You received a personal badge!

<table><tr><td>https://images.hive.blog/70x70/http://hivebuzz.me/badges/birthday-3.png</td><td>Happy Hive Birthday! You are on the Hive blockchain for 3 years!</td></tr></table>

<sub>_You can view your badges on [your board](https://hivebuzz.me/@brianoflondon) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub>


**Check out the last post from @hivebuzz:**
<table><tr><td><a href="/hivebuzz/@hivebuzz/pud-202108"><img src="https://images.hive.blog/64x128/https://i.imgur.com/805FIIt.jpg"></a></td><td><a href="/hivebuzz/@hivebuzz/pud-202108">Hive Power Up Day - August 1st 2021 - Hive Power Delegation</a></td></tr></table>
properties (22)
authorhivebuzz
permlinkhivebuzz-notify-brianoflondon-20210727t134530000z
categoryprogramming
json_metadata{"image":["http://hivebuzz.me/notify.t6.png"]}
created2021-07-27 13:45:30
last_update2021-07-27 13:45:30
depth1
children0
last_payout2021-08-03 13:45:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length722
author_reputation368,402,736,822,151
root_title"Python Help: what database should I use for sending Lightning Streaming Sats into Hive for Podcasting 2.0?"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id105,151,523
net_rshares0