Set up database creation on start.

This commit is contained in:
iamBadgers
2026-04-09 23:17:42 -07:00
parent e475dbc36b
commit c63e9b19bd
4 changed files with 49 additions and 22 deletions

View File

@@ -9,6 +9,33 @@ def get_db():
return db
_game_table_create = """
CREATE TABLE IF NOT EXISTS "game_tables" (
"game_table_id" INTEGER NOT NULL UNIQUE,
"game_table_name" TEXT UNIQUE,
"game_table_link" TEXT UNIQUE,
"active" INTEGER DEFAULT 0,
"game_key" TEXT,
"docker_id" TEXT,
PRIMARY KEY("game_table_id")
);
"""
_key_table_create = """
CREATE TABLE IF NOT EXISTS "game_keys" (
"key" TEXT NOT NULL,
"game_table_id" INTEGER,
PRIMARY KEY("key")
);
"""
def init_db(connection):
with SmartCursor(connection=connection) as smart_cursor:
smart_cursor.execute(_game_table_create)
smart_cursor.execute(_key_table_create)
connection.commit()
class SmartCursor:
connection: Connection
curosr: Cursor