-
Notifications
You must be signed in to change notification settings - Fork 2
/
init_db.py
70 lines (59 loc) · 1.59 KB
/
init_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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from sqlalchemy import create_engine
from diet_manager import db
from diet_manager.models import User, Product
def db_start():
create_engine('sqlite:///diet_manager.db', convert_unicode=True)
db.create_all()
db.session.commit()
user = User()
user.name = "krystyna"
user.email = '[email protected]'
user.set_password('superhaslo')
user.weight = 50
user.height = 150
user.admin = True
user.patron = True
db.session.add(user)
db.session.commit()
product = Product()
product.name = "jabłko"
product.calories = 46
product.protein = 0.4
product.fat = 0.4
product.carbohydrates = 12.1
db.session.add(product)
db.session.commit()
product2 = Product()
product2.name = "marchew"
product2.calories = 27
product2.protein = 1
product2.fat = 0.2
product2.carbohydrates = 8.7
db.session.add(product2)
db.session.commit()
product3 = Product()
product3.name = "banan"
product3.calories = 97
product3.protein = 1
product3.fat = 0.3
product3.carbohydrates = 23.5
db.session.add(product3)
db.session.commit()
product4 = Product()
product4.name = "jajko"
product4.calories = 140
product4.protein = 12.5
product4.fat = 9.7
product4.carbohydrates = 0.6
db.session.add(product4)
db.session.commit()
product5 = Product()
product5.name = "pomidor"
product5.calories = 15
product5.protein = 0.9
product5.fat = 0.2
product5.carbohydrates = 3.6
db.session.add(product5)
db.session.commit()
if __name__ == '__main__':
db_start()