fix: ensure database is initialized before operations to resolve OperationalError
This commit is contained in:
parent
0f547aa1dc
commit
275df31213
@ -9,7 +9,7 @@ app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
|||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
init_db()
|
init_db() # Ensure the database is initialized before any operations
|
||||||
|
|
||||||
@app.route('/games', methods=['POST'])
|
@app.route('/games', methods=['POST'])
|
||||||
def add_game():
|
def add_game():
|
||||||
@ -38,4 +38,6 @@ def get_games():
|
|||||||
} for game in games])
|
} for game in games])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
with app.app_context():
|
||||||
|
init_db() # Ensure the database is initialized when the app starts
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user