-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanage.py
40 lines (30 loc) · 1012 Bytes
/
manage.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
30
31
32
33
34
35
36
37
38
39
40
'''Calling methods to create and drop tables and create admin'''
from app.api.v2.model import User, FoodMenu, FoodOrder
from run import app
from app.api.v2.database import DatabaseConnection
class Connection(DatabaseConnection):
def __init__(self):
super().__init__()
def drop(self):
'''drop all tables'''
User().drop_tables()
FoodOrder().drop_tables()
FoodMenu().drop_tables()
def create(self):
'''craetes tables'''
foodorder = FoodOrder()
foodorder.create_table()
foodmenu = FoodMenu()
foodmenu.create_table()
user = User()
user.create_table()
def create_admin(self):
'''creates an admin'''
admin = User(username='Admin', email='[email protected]',
password='Admin123', is_admin=True)
admin.add()
if __name__ == '__main__':
with app.app_context():
Connection().drop()
Connection().create()
Connection().create_admin()