-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_db.py
29 lines (22 loc) · 1002 Bytes
/
setup_db.py
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
# Launch flask shell and run these commands
# docker compose exec salesdemo flask shell
db.drop_all()
db.create_all()
users = [
{'first_name': 'Scott', 'last_name': 'Tiger', 'username': 'stiger', 'email': '[email protected]'},
{'first_name': 'Mickey', 'last_name': 'Mouse', 'username': 'mmouse', 'email': '[email protected]'},
{'first_name': 'Charlie', 'last_name': 'Chaplin', 'username': 'cchaplin', 'email': '[email protected]'}
]
for user in users:
user_rec = User(**user)
db.session.add(user_rec)
db.session.commit()
courses = [
{'course_name': 'Mastering Python', 'course_author': 'Scott Tiger', 'course_endpoint': 'mastering-python'},
{'course_name': 'Python App Development', 'course_author': 'Donald Duck', 'course_endpoint': 'python-app-development'},
{'course_name': 'DevOps Bootcamp', 'course_author': 'Mickey Mouse', 'course_endpoint': 'devops-bootcamp'}
]
for item in courses:
course = Course(**item)
db.session.add(course)
db.session.commit()