fix livestream for postgres compatibility
fix producers create returning id
This commit is contained in:
parent
1c0a4e252a
commit
4ce0ed63c0
1 changed files with 10 additions and 3 deletions
|
|
@ -160,14 +160,21 @@ async def add_producer(livestream: int, name: str) -> int:
|
||||||
user = await create_account()
|
user = await create_account()
|
||||||
wallet = await create_wallet(user_id=user.id, wallet_name="livestream: " + name)
|
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)
|
INSERT INTO livestream.producers (livestream, name, "user", wallet)
|
||||||
VALUES (?, ?, ?, ?)
|
VALUES (?, ?, ?, ?)
|
||||||
|
{returning}
|
||||||
""",
|
""",
|
||||||
(livestream, name, user.id, wallet.id),
|
(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]:
|
async def get_producer(producer_id: int) -> Optional[Producer]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue