mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-23 14:40:47 +01:00
remove quotes from streamalerts table names.
This commit is contained in:
parent
a019d29b9b
commit
9c31d06112
2 changed files with 20 additions and 22 deletions
|
@ -54,7 +54,7 @@ async def create_donation(
|
|||
"""Create a new Donation"""
|
||||
await db.execute(
|
||||
"""
|
||||
INSERT INTO streamalerts."Donations" (
|
||||
INSERT INTO streamalerts.Donations (
|
||||
id,
|
||||
wallet,
|
||||
name,
|
||||
|
@ -108,7 +108,7 @@ async def post_donation(donation_id: str) -> tuple:
|
|||
else:
|
||||
return (jsonify({"message": "Unsopported servicename"}), HTTPStatus.BAD_REQUEST)
|
||||
await db.execute(
|
||||
'UPDATE streamalerts."Donations" SET posted = 1 WHERE id = ?', (donation_id,)
|
||||
"UPDATE streamalerts.Donations SET posted = 1 WHERE id = ?", (donation_id,)
|
||||
)
|
||||
return (jsonify(response.json()), status)
|
||||
|
||||
|
@ -125,7 +125,7 @@ async def create_service(
|
|||
"""Create a new Service"""
|
||||
result = await db.execute(
|
||||
"""
|
||||
INSERT INTO streamalerts."Services" (
|
||||
INSERT INTO streamalerts.Services (
|
||||
twitchuser,
|
||||
client_id,
|
||||
client_secret,
|
||||
|
@ -162,11 +162,11 @@ async def get_service(service_id: int, by_state: str = None) -> Optional[Service
|
|||
"""
|
||||
if by_state:
|
||||
row = await db.fetchone(
|
||||
'SELECT * FROM streamalerts."Services" WHERE state = ?', (by_state,)
|
||||
"SELECT * FROM streamalerts.Services WHERE state = ?", (by_state,)
|
||||
)
|
||||
else:
|
||||
row = await db.fetchone(
|
||||
'SELECT * FROM streamalerts."Services" WHERE id = ?', (service_id,)
|
||||
"SELECT * FROM streamalerts.Services WHERE id = ?", (service_id,)
|
||||
)
|
||||
return Service.from_row(row) if row else None
|
||||
|
||||
|
@ -174,7 +174,7 @@ async def get_service(service_id: int, by_state: str = None) -> Optional[Service
|
|||
async def get_services(wallet_id: str) -> Optional[list]:
|
||||
"""Return all services belonging assigned to the wallet_id"""
|
||||
rows = await db.fetchall(
|
||||
'SELECT * FROM streamalerts."Services" WHERE wallet = ?', (wallet_id,)
|
||||
"SELECT * FROM streamalerts.Services WHERE wallet = ?", (wallet_id,)
|
||||
)
|
||||
return [Service.from_row(row) for row in rows] if rows else None
|
||||
|
||||
|
@ -212,7 +212,7 @@ async def service_add_token(service_id, token):
|
|||
if (await get_service(service_id)).authenticated:
|
||||
return False
|
||||
await db.execute(
|
||||
'UPDATE streamalerts."Services" SET authenticated = 1, token = ? where id = ?',
|
||||
"UPDATE streamalerts.Services SET authenticated = 1, token = ? where id = ?",
|
||||
(
|
||||
token,
|
||||
service_id,
|
||||
|
@ -223,9 +223,9 @@ async def service_add_token(service_id, token):
|
|||
|
||||
async def delete_service(service_id: int) -> None:
|
||||
"""Delete a Service and all corresponding Donations"""
|
||||
await db.execute('DELETE FROM streamalerts."Services" WHERE id = ?', (service_id,))
|
||||
await db.execute("DELETE FROM streamalerts.Services WHERE id = ?", (service_id,))
|
||||
rows = await db.fetchall(
|
||||
'SELECT * FROM streamalerts."Donations" WHERE service = ?', (service_id,)
|
||||
"SELECT * FROM streamalerts.Donations WHERE service = ?", (service_id,)
|
||||
)
|
||||
for row in rows:
|
||||
await delete_donation(row["id"])
|
||||
|
@ -234,24 +234,22 @@ async def delete_service(service_id: int) -> None:
|
|||
async def get_donation(donation_id: str) -> Optional[Donation]:
|
||||
"""Return a Donation"""
|
||||
row = await db.fetchone(
|
||||
'SELECT * FROM streamalerts."Donations" WHERE id = ?', (donation_id,)
|
||||
"SELECT * FROM streamalerts.Donations WHERE id = ?", (donation_id,)
|
||||
)
|
||||
return Donation.from_row(row) if row else None
|
||||
|
||||
|
||||
async def get_donations(wallet_id: str) -> Optional[list]:
|
||||
"""Return all streamalerts."Donations" assigned to wallet_id"""
|
||||
"""Return all streamalerts.Donations assigned to wallet_id"""
|
||||
rows = await db.fetchall(
|
||||
'SELECT * FROM streamalerts."Donations" WHERE wallet = ?', (wallet_id,)
|
||||
"SELECT * FROM streamalerts.Donations WHERE wallet = ?", (wallet_id,)
|
||||
)
|
||||
return [Donation.from_row(row) for row in rows] if rows else None
|
||||
|
||||
|
||||
async def delete_donation(donation_id: str) -> None:
|
||||
"""Delete a Donation and its corresponding statspay charge"""
|
||||
await db.execute(
|
||||
'DELETE FROM streamalerts."Donations" WHERE id = ?', (donation_id,)
|
||||
)
|
||||
await db.execute("DELETE FROM streamalerts.Donations WHERE id = ?", (donation_id,))
|
||||
await delete_charge(donation_id)
|
||||
|
||||
|
||||
|
@ -259,11 +257,11 @@ async def update_donation(donation_id: str, **kwargs) -> Donation:
|
|||
"""Update a Donation"""
|
||||
q = ", ".join([f"{field[0]} = ?" for field in kwargs.items()])
|
||||
await db.execute(
|
||||
f'UPDATE streamalerts."Donations" SET {q} WHERE id = ?',
|
||||
f"UPDATE streamalerts.Donations SET {q} WHERE id = ?",
|
||||
(*kwargs.values(), donation_id),
|
||||
)
|
||||
row = await db.fetchone(
|
||||
'SELECT * FROM streamalerts."Donations" WHERE id = ?', (donation_id,)
|
||||
"SELECT * FROM streamalerts.Donations WHERE id = ?", (donation_id,)
|
||||
)
|
||||
assert row, "Newly updated donation couldn't be retrieved"
|
||||
return Donation(**row)
|
||||
|
@ -273,11 +271,11 @@ async def update_service(service_id: str, **kwargs) -> Service:
|
|||
"""Update a service"""
|
||||
q = ", ".join([f"{field[0]} = ?" for field in kwargs.items()])
|
||||
await db.execute(
|
||||
f'UPDATE streamalerts."Services" SET {q} WHERE id = ?',
|
||||
f"UPDATE streamalerts.Services SET {q} WHERE id = ?",
|
||||
(*kwargs.values(), service_id),
|
||||
)
|
||||
row = await db.fetchone(
|
||||
'SELECT * FROM streamalerts."Services" WHERE id = ?', (service_id,)
|
||||
"SELECT * FROM streamalerts.Services WHERE id = ?", (service_id,)
|
||||
)
|
||||
assert row, "Newly updated service couldn't be retrieved"
|
||||
return Service(**row)
|
||||
|
|
|
@ -2,7 +2,7 @@ async def m001_initial(db):
|
|||
|
||||
await db.execute(
|
||||
f"""
|
||||
CREATE TABLE IF NOT EXISTS streamalerts."Services" (
|
||||
CREATE TABLE IF NOT EXISTS streamalerts.Services (
|
||||
id {db.serial_primary_key},
|
||||
state TEXT NOT NULL,
|
||||
twitchuser TEXT NOT NULL,
|
||||
|
@ -19,7 +19,7 @@ async def m001_initial(db):
|
|||
|
||||
await db.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS streamalerts."Donations" (
|
||||
CREATE TABLE IF NOT EXISTS streamalerts.Donations (
|
||||
id TEXT PRIMARY KEY,
|
||||
wallet TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
|
@ -29,7 +29,7 @@ async def m001_initial(db):
|
|||
amount FLOAT NOT NULL,
|
||||
service INTEGER NOT NULL,
|
||||
posted BOOLEAN NOT NULL,
|
||||
FOREIGN KEY(service) REFERENCES streamalerts."Services" (id)
|
||||
FOREIGN KEY(service) REFERENCES streamalerts.Services (id)
|
||||
);
|
||||
"""
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue