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.
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 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.
- Vote for APSHamilton's Witness KeyChain or HiveSigner
- Vote for APSHamilton's Witness direct with HiveSigner
- Get Brave
- Use my referral link for crypto.com to sign up and we both get $25 USD
- Sign up for BlockFi
- Find my videos on 3speak
- Join the JPBLiberty Class Action law suit
- Verify my ID and Send me a direct message on Keybase