25 lines
614 B
Python
25 lines
614 B
Python
from app import app, db, Frage
|
|
|
|
|
|
def init_db():
|
|
# Ensure we run DB commands inside the Flask application context
|
|
with app.app_context():
|
|
db.drop_all()
|
|
db.create_all()
|
|
|
|
sample = [
|
|
'Haben Sie besondere Ernährungsbedürfnisse?',
|
|
'Benötigen Sie eine Übernachtung?',
|
|
'Möchten Sie unseren Newsletter erhalten?'
|
|
]
|
|
for text in sample:
|
|
f = Frage(text=text)
|
|
db.session.add(f)
|
|
db.session.commit()
|
|
|
|
print('DB initialisiert und Beispiel-Fragen angelegt.')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
init_db()
|