mirror of
https://github.com/lnbits/lnbits.git
synced 2025-04-20 21:44:13 +02:00
fix livestream for postgres compatibility
fix producers create returning id
This commit is contained in:
parent
1c0a4e252a
commit
4ce0ed63c0
@ -160,14 +160,21 @@ async def add_producer(livestream: int, name: str) -> int:
|
||||
user = await create_account()
|
||||
wallet = await create_wallet(user_id=user.id, wallet_name="livestream: " + name)
|
||||
|
||||
result = await db.execute(
|
||||
"""
|
||||
returning = "" if db.type == SQLITE else "RETURNING ID"
|
||||
method = db.execute if db.type == SQLITE else db.fetchone
|
||||
|
||||
result = await method(
|
||||
f"""
|
||||
INSERT INTO livestream.producers (livestream, name, "user", wallet)
|
||||
VALUES (?, ?, ?, ?)
|
||||
{returning}
|
||||
""",
|
||||
(livestream, name, user.id, wallet.id),
|
||||
)
|
||||
return result._result_proxy.lastrowid
|
||||
if db.type == SQLITE:
|
||||
return result._result_proxy.lastrowid
|
||||
else:
|
||||
return result[0]
|
||||
|
||||
|
||||
async def get_producer(producer_id: int) -> Optional[Producer]:
|
||||
|
Loading…
x
Reference in New Issue
Block a user