Initial tansition to SQLAlchemy on the Game Table resource
This commit is contained in:
12
src/main.py
12
src/main.py
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user