-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfirst_deploy.py
More file actions
33 lines (23 loc) · 756 Bytes
/
first_deploy.py
File metadata and controls
33 lines (23 loc) · 756 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
from app import db, create_app
from app.models import Group, Educator
def create_obj():
first_group = Group(id=0, title="No Group")
db.session.add(first_group)
first_edu = Educator(id=0, title="No Educator")
db.session.add(first_edu)
db.session.commit()
def check_obj():
first_group = Group.query.filter_by(title="No Group").first()
if first_group.id != 0:
first_group.id = 0
db.session.add(first_group)
first_edu = Educator.query.filter_by(title="No Educator").first()
if first_edu.id != 0:
first_edu.id = 0
db.session.add(first_edu)
db.session.commit()
if __name__ == "__main__":
app = create_app()
with app.app_context():
create_obj()
check_obj()