Création d'une page de gestion des humeurs

This commit is contained in:
Kepka Ludovic
2025-08-09 09:08:27 +02:00
parent 21b5cf8669
commit 7db8b1ff7b
11 changed files with 77 additions and 21 deletions

View File

@@ -6,7 +6,12 @@ webapp.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db'
db = SQLAlchemy(webapp)
with webapp.app_context():
with open('database/schema.sql', 'r') as f:
sql_script = f.read()
db.session.execute(text(sql_script))
db.session.commit()
with open('database/schema.sql', 'r') as f:
sql = f.read()
connection = db.session.connection().connection
try:
cursor = connection.cursor()
cursor.executescript(sql)
cursor.close()
finally:
connection.close()