fix: ensure database is initialized before operations to resolve OperationalError

This commit is contained in:
Manuel Weiser 2024-09-02 09:32:28 +02:00
parent 0f547aa1dc
commit 275df31213

View File

@ -9,7 +9,7 @@ app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app)
with app.app_context():
init_db()
init_db() # Ensure the database is initialized before any operations
@app.route('/games', methods=['POST'])
def add_game():
@ -38,4 +38,6 @@ def get_games():
} for game in games])
if __name__ == '__main__':
with app.app_context():
init_db() # Ensure the database is initialized when the app starts
app.run(debug=True)