postgres support.

This commit is contained in:
fiatjaf
2021-07-02 17:34:31 -03:00
parent eeb3e66529
commit 2f309c9863
54 changed files with 624 additions and 540 deletions
+3 -3
View File
@@ -5,17 +5,17 @@ from .models import Target
async def get_targets(source_wallet: str) -> List[Target]:
rows = await db.fetchall("SELECT * FROM targets WHERE source = ?", (source_wallet,))
rows = await db.fetchall("SELECT * FROM splitpayments.targets WHERE source = ?", (source_wallet,))
return [Target(**dict(row)) for row in rows]
async def set_targets(source_wallet: str, targets: List[Target]):
async with db.connect() as conn:
await conn.execute("DELETE FROM targets WHERE source = ?", (source_wallet,))
await conn.execute("DELETE FROM splitpayments.targets WHERE source = ?", (source_wallet,))
for target in targets:
await conn.execute(
"""
INSERT INTO targets
INSERT INTO splitpayments.targets
(source, wallet, percent, alias)
VALUES (?, ?, ?, ?)
""",
@@ -4,7 +4,7 @@ async def m001_initial(db):
"""
await db.execute(
"""
CREATE TABLE IF NOT EXISTS targets (
CREATE TABLE splitpayments.targets (
wallet TEXT NOT NULL,
source TEXT NOT NULL,
percent INTEGER NOT NULL CHECK (percent >= 0 AND percent <= 100),
+1 -1
View File
@@ -47,7 +47,7 @@ async def on_invoice_paid(payment: Payment) -> None:
# and reduce it by the amount we're going to send to the producer
await core_db.execute(
"""
UPDATE apipayments
UPDATE splitpayments.apipayments
SET extra = ?, amount = ?
WHERE hash = ?
AND checking_id NOT LIKE 'internal_%'