Initial tansition to SQLAlchemy on the Game Table resource

This commit is contained in:
iamBadgers
2026-04-22 22:16:27 -07:00
parent a0bc0f0feb
commit b6cef4f3c1
9 changed files with 75 additions and 51 deletions

View File

@@ -2,19 +2,27 @@ from flask import Flask, g, jsonify, request
import sqlite3
import container_managment
from database import SmartCursor, get_db, init_db
import tables
import os
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
def create_app():
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////data/tables.db"
db.init_app(app)
@app.teardown_appcontext
def close_connection(exception):
db = getattr(g, "_database", None)
if db is not None:
db.close()
import tables
app.register_blueprint(tables.tables, url_prefix="/api")
with app.app_context():
@@ -24,4 +32,4 @@ def create_app():
if __name__ == "__main__":
create_app.run(debug=True)
create_app().run(debug=True)