mirror of
https://github.com/skylanix/MamieHenriette.git
synced 2026-04-17 08:36:48 +02:00
Création d'une page de gestion des humeurs
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
# from webapp import db
|
||||
from database import db
|
||||
|
||||
class Humeur(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
enable = db.Column(db.Boolean, default=True)
|
||||
text = db.Column(db.String(200))
|
||||
|
||||
class Message(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
enable = db.Column(db.Boolean, default=False)
|
||||
@@ -3,4 +3,10 @@ CREATE TABLE IF NOT EXISTS `message` (
|
||||
`enable` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`text` VARCHAR(256) NULL,
|
||||
periodicity INTEGER NULL
|
||||
);
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `humeur` (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`enable` BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
`text` VARCHAR(256) NULL
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user