-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopulate.py
More file actions
35 lines (26 loc) · 911 Bytes
/
populate.py
File metadata and controls
35 lines (26 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from database import db
from factory import create_app
from feynman.users.utils.populate import populate_users
from feynman.workshops.utils.populate import populate_workshops
from feynman.events.utils.populate import populate_events
from feynman.participations.utils.populate import populate_participations
def populate_db():
print('populating users...')
users = populate_users()
print('populating workshops...')
workshops = populate_workshops()
for workshop in workshops:
print(' populating events...')
events = populate_events(workshop)
for event in events:
print(' populating participations...')
populate_participations(event, users, 5)
def reset_db():
db.reflect()
db.drop_all()
db.create_all()
if __name__ == '__main__':
app = create_app()
with app.app_context():
reset_db()
populate_db()