From 7aa99f3a6bfe54ac5ff168efd4f2c768d67ec1c9 Mon Sep 17 00:00:00 2001 From: iamBadgers Date: Sun, 17 May 2026 17:39:45 -0700 Subject: [PATCH] Update database creation so I dont have to manually fsk with it anymore. --- src/database.py | 40 ---------------------------------------- src/main.py | 4 ++-- 2 files changed, 2 insertions(+), 42 deletions(-) diff --git a/src/database.py b/src/database.py index 1f9b7f6..0f83f57 100644 --- a/src/database.py +++ b/src/database.py @@ -10,46 +10,6 @@ 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, - "version" INTEGER, - "active" INTEGER, - "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, - "key_file" TEXT NOT NULL, - PRIMARY KEY("key") -); -""" - -_user_table_create = """ -CREATE TABLE IF NOT EXISTS "users" ( - "id" INTEGER NOT NULL, - "username" TEXT NOT NULL, - "hash" TEXT NOT NULL, - PRIMARY KEY ("id") -); -""" - - -def init_db(connection): - with SmartCursor(connection=connection) as smart_cursor: - smart_cursor.execute(_game_table_create) - smart_cursor.execute(_key_table_create) - smart_cursor.execute(_user_table_create) - connection.commit() - - class SmartCursor: connection: Connection curosr: Cursor diff --git a/src/main.py b/src/main.py index de2a9e7..3967c89 100644 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,6 @@ from flask import Flask, g, jsonify, request import sqlite3 -from database import SmartCursor, get_db, init_db +from database import SmartCursor, get_db from flask_sqlalchemy import SQLAlchemy from flask_login import LoginManager @@ -37,7 +37,7 @@ def create_app(): app.register_blueprint(auth.auth, url_prefix="/api/auth") with app.app_context(): - init_db(get_db()) + db.create_all() return app