add database schemas and general queries

This commit is contained in:
2025-05-06 20:50:10 +02:00
parent 77f22b64d3
commit 0eb4256111

32
src/logic/db_schemas.py Normal file
View File

@@ -0,0 +1,32 @@
KOMGRABBER_TABLE = """
CREATE TABLE IF NOT EXISTS komgrabber (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
series_id TEXT NOT NULL,
status TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_checked TIMESTAMP DEFAULT 0
);
"""
INSERT_KOMGRABBER = """
INSERT INTO komgrabber (name, series_id, status)
VALUES (?, ?, ?);
"""
SELECT_KOMGRABBER = """
SELECT * FROM komgrabber WHERE series_id = ?;
"""
UPDATE_KOMGRABBER = """
UPDATE komgrabber
SET name = ?, status = ?, updated_at = CURRENT_TIMESTAMP
WHERE series_id = ?;
"""
LASTCHECKED_KOMGRABBER = """
UPDATE komgrabber
SET last_checked = CURRENT_TIMESTAMP
WHERE series_id = ?;
"""
GET_LASTCHECKED_KOMGRABBER = """
SELECT last_checked FROM komgrabber WHERE series_id = ?;
"""