Filter and tokens update

This commit is contained in:
2026-06-13 12:28:58 -05:00
parent 1c4659c1ae
commit 593a6756f6
6 changed files with 338 additions and 154 deletions
+17 -7
View File
@@ -12,6 +12,12 @@ def conn():
return c
def _add_column(c, table, col, decl):
cols = [r[1] for r in c.execute(f"PRAGMA table_info({table})").fetchall()]
if col not in cols:
c.execute(f"ALTER TABLE {table} ADD COLUMN {col} {decl}")
def init():
DB_PATH.parent.mkdir(parents=True, exist_ok=True)
with conn() as c:
@@ -26,13 +32,15 @@ def init():
total INTEGER DEFAULT 0
);
CREATE TABLE IF NOT EXISTS cards (
id INTEGER PRIMARY KEY AUTOINCREMENT,
deck_slug TEXT NOT NULL REFERENCES decks(slug) ON DELETE CASCADE,
name TEXT NOT NULL,
position INTEGER NOT NULL,
filename TEXT,
price_usd REAL DEFAULT 0,
fetch_status TEXT DEFAULT 'pending'
id INTEGER PRIMARY KEY AUTOINCREMENT,
deck_slug TEXT NOT NULL REFERENCES decks(slug) ON DELETE CASCADE,
name TEXT NOT NULL,
position INTEGER NOT NULL,
filename TEXT,
back_filename TEXT,
scry_url TEXT,
price_usd REAL DEFAULT 0,
fetch_status TEXT DEFAULT 'pending'
);
CREATE TABLE IF NOT EXISTS logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -40,6 +48,8 @@ def init():
line TEXT NOT NULL
);
""")
_add_column(c, "cards", "back_filename", "TEXT")
_add_column(c, "cards", "scry_url", "TEXT")
def get_deck(slug: str):