-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed.py
147 lines (97 loc) · 4.11 KB
/
seed.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
from datetime import datetime
from model import (db, connect_to_db, User, Symptom, Meal)
from server import app
def load_users():
"""Load fake users into database"""
User.query.delete()
print('Adding users...')
user_1 = User(email='[email protected]', password='fluffy89')
user_2 = User(email='[email protected]', password='secure-password')
user_3 = User(email='[email protected]', password='password123')
db.session.add_all([user_1, user_2, user_3])
db.session.commit()
print('Users added!')
def load_symptoms():
"""Add smyptoms into the database"""
Symptom.query.delete()
print('Adding symptoms...')
symp_1 = Symptom(name='heartburn')
symp_2 = Symptom(name='migraine')
symp_3 = Symptom(name='nausea')
symp_4 = Symptom(name='indigestion')
symp_5 = Symptom(name='upset stomach')
db.session.add_all([symp_1, symp_2, symp_3, symp_4, symp_5])
db.session.commit()
print('Symptoms added!')
# def load_foods():
# """Add some foods into the database"""
# Food.query.delete()
# print('Adding foods...')
# food_1 = Food(name='Kraft Macaroni And Cheese Dinner', brand_name='Kraft')
# food_2 = Food(name='Pumpkin Chia Pudding', brand_name='Thistle')
# # nix_item_id = 51d2ff1dcc9bff111580f5e4
# db.session.add_all([food_1, food_2])
# db.session.commit()
# def load_ingredients():
# Ingredient.query.delete()
# print('Adding ingredients...')
# ingrd_1 = Ingredient(name='wheat flour')
# ingrd_2 = Ingredient(name='niacin')
# ingrd_3 = Ingredient(name='milkfat')
# ingrd_4 = Ingredient(name='salt')
# ingrd_5 = Ingredient(name='whey')
# ingrd_6 = Ingredient(name='hemp milk')
# ingrd_7 = Ingredient(name='pumpkin')
# ingrd_8 = Ingredient(name='banana')
# ingrd_9 = Ingredient(name='maple syrup')
# ingrd_10 = Ingredient(name='chia seeds')
# ingrd_11 = Ingredient(name='pea protein powder')
# ingrd_12 = Ingredient(name='orange zest')
# db.session.add_all([ingrd_1, ingrd_2, ingrd_3, ingrd_4, ingrd_5,
# ingrd_6, ingrd_7, ingrd_8, ingrd_9, ingrd_10, ingrd_11,
# ingrd_12])
# db.session.commit()
# def load_food_ingredients():
# FoodIngredient.query.delete()
# print('Adding food ingredients...')
# food_ingrd_1 = FoodIngredient(food_id=1, ingredient_id=1)
# food_ingrd_2 = FoodIngredient(food_id=1, ingredient_id=2)
# food_ingrd_3 = FoodIngredient(food_id=1, ingredient_id=3)
# food_ingrd_4 = FoodIngredient(food_id=1, ingredient_id=4)
# food_ingrd_5 = FoodIngredient(food_id=1, ingredient_id=5)
# food_ingrd_6 = FoodIngredient(food_id=2, ingredient_id=6)
# food_ingrd_7 = FoodIngredient(food_id=2, ingredient_id=7)
# food_ingrd_8 = FoodIngredient(food_id=2, ingredient_id=8)
# food_ingrd_9 = FoodIngredient(food_id=2, ingredient_id=9)
# food_ingrd_10 = FoodIngredient(food_id=2, ingredient_id=10)
# food_ingrd_11 = FoodIngredient(food_id=2, ingredient_id=11)
# food_ingrd_12 = FoodIngredient(food_id=2, ingredient_id=12)
# db.session.add_all([food_ingrd_1, food_ingrd_2, food_ingrd_3, food_ingrd_4,
# food_ingrd_5, food_ingrd_6, food_ingrd_7, food_ingrd_8,
# food_ingrd_9, food_ingrd_10, food_ingrd_11, food_ingrd_12])
# db.session.commit()
def load_meals():
meal_1 = Meal(name='breakfast')
meal_2 = Meal(name='lunch')
meal_3 = Meal(name='dinner')
meal_4 = Meal(name='snacks')
db.session.add_all([meal_1, meal_2, meal_3, meal_4])
db.session.commit()
# def load_food_logs():
# FoodLog.query.delete()
# print('Adding food logs...')
# food_log_1 = FoodLog(ts=datetime.now(), meal_id=2, user_id=1, food_id=1)
# food_log_2 = FoodLog(ts=datetime.now(), meal_id=1, user_id=1, food_id=2)
# db.session.add_all([food_log_1, food_log_2])
# db.session.commit()
if __name__ == "__main__":
connect_to_db(app)
db.create_all()
load_users()
load_symptoms()
# load_foods()
# load_ingredients()
# load_food_ingredients()
load_meals()
# load_food_logs()
print('All done!')