-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed.py
157 lines (135 loc) · 3.47 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
148
149
150
151
152
153
154
155
156
157
from server.app import app
from server.models import db, Restaurant, Pizza, RestaurantPizza
from faker import Faker
import random
ke_restaurants = [
"Java House",
"Artcaffe",
"Cafe Deli",
"Kilimanjaro Jamia",
"Villa Rosa Kempinski",
"Carnivore Restaurant",
"Talisman Restaurant",
"Mama Oliech Restaurant",
"Nyama Mama",
"Habesha Restaurant",
"The Talisman",
"Mama Rocks Gourmet Burgers",
"About Thyme Restaurant",
"Cafe Maghreb",
"Lord Erroll Gourmet Restaurant",
"Que Pasa Bar & Bistro",
"Sankara Nairobi, Sarabi Rooftop Bar",
"Anghiti Restaurant",
"Seven Seafood & Grill",
"Zen Garden",
"Hashmi BBQ",
"Le Palanka"
]
pizza_flavors = [
"Margherita",
"Pepperoni",
"Hawaiian",
"Supreme",
"BBQ Chicken",
"Veggie Supreme",
"Meat Lovers",
"Buffalo Chicken",
"Mushroom and Swiss",
"White Garlic",
"Pesto and Tomato",
"Four Cheese",
"Spinach and Feta",
"Sausage and Peppers",
"Mediterranean",
"BBQ Pulled Pork",
"Shrimp Scampi",
"Taco Pizza",
"Alfredo Chicken",
"BLT Pizza",
"Philly Cheesesteak",
"Caprese",
"Greek Pizza",
"Breakfast Pizza",
"Truffle and Mushroom"
]
pizza_ingredients = [
"Tomato Sauce",
"Mozzarella Cheese",
"Pepperoni Slices",
"Ham",
"Pineapple Chunks",
"Green Bell Pepper",
"Onion",
"Olives",
"Mushrooms",
"BBQ Sauce",
"Grilled Chicken",
"Red Onion",
"Bacon",
"Ranch Dressing",
"Garlic Sauce",
"Parmesan Cheese",
"Pesto Sauce",
"Tomato Slices",
"Cheddar Cheese",
"Sausage",
"Jalapeno Peppers",
"Feta Cheese",
"Shrimp",
"Taco Seasoning",
"Alfredo Sauce",
"Lettuce",
"Tomato",
"Beef",
"Mayonnaise",
"Ketchup",
"Philly Steak",
"Fresh Basil",
"Mozzarella Pearls",
"Kalamata Olives",
"Eggs",
"Béchamel Sauce",
"Truffle Oil",
]
fake = Faker()
if __name__ == '__main__':
with app.app_context():
Restaurant.query.delete()
Pizza.query.delete()
RestaurantPizza.query.delete()
restaurants = []
for res in ke_restaurants:
restaurant = Restaurant(
name=res,
address=f"{fake.street_address()}, Nairobi"
)
restaurants.append(restaurant)
db.session.add_all(restaurants)
pizzas = []
for pz in pizza_flavors:
all_ingredients = {
f"{random.choice(pizza_ingredients)}, " +\
f"{random.choice(pizza_ingredients)}, " +\
f"{random.choice(pizza_ingredients)}, " +\
f"{random.choice(pizza_ingredients)}, " +\
f"{random.choice(pizza_ingredients)}"
}
pizza = Pizza(
name=pz,
ingredients=', '.join(all_ingredients)
)
pizzas.append(pizza)
db.session.add_all(pizzas)
restaurant_pizzas = []
for restaurant in restaurants:
for i in range(random.randint(1, 4)):
restaurant_pizza=RestaurantPizza(
price=random.randint(1, 30),
restaurant=restaurant,
pizza=random.choice(pizzas)
)
restaurant_pizzas.append(restaurant_pizza)
db.session.add_all(restaurant_pizzas)
db.session.commit()
print("Db seeded successfully.")