-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopulate_db.py
212 lines (141 loc) · 8.07 KB
/
populate_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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from database_setup import Restaurant, Base, MenuItem, User
engine = create_engine('sqlite:///restaurantmenuwithusers.db')
# Bind the engine to the metadata of the Base class so that the
# declaratives can be accessed through a DBSession instance
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
# A DBSession() instance establishes all conversations with the database
# and represents a "staging zone" for all the objects loaded into the
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()
# Create dummy user
User1 = User(name="Girish Thavai", email="[email protected]",
picture='https://freeiconshop.com/wp-content/uploads/edd/person-outline-filled.png')
session.add(User1)
session.commit()
print("User created: " + User1.name)
# Menu for Fusion Kadai
restaurant1 = Restaurant(user_id=1, name="Fusion Kadai")
session.add(restaurant1)
session.commit()
menuItem1 = MenuItem(user_id=1, name="French Chat", description="Desi Chat with garlic and parmesan",
price="₹150", course="Appetizers", restaurant=restaurant1)
session.add(menuItem1)
session.commit()
menuItem2 = MenuItem(user_id=1, name="Chaat Papdi", description="Fried papdi mixed with onions, tomatoes, mint, tamarind & yogurt",
price="₹100", course="Appetizers", restaurant=restaurant1)
session.add(menuItem2)
session.commit()
menuItem3 = MenuItem(user_id=1, name="Paneer Pakora", description="Cottage cheese dipped in chickpea batter and fried",
price="₹200", course="Starters", restaurant=restaurant1)
session.add(menuItem3)
session.commit()
menuItem4 = MenuItem(user_id=1, name="Coconut Soup", description="Coconut milk, light onion sauce with fresh cream",
price="₹250", course="Appetizers", restaurant=restaurant1)
session.add(menuItem4)
session.commit()
menuItem5 = MenuItem(user_id=1, name="Gulab Jamun", description="Deep fried milk confection in a sweet syrup",
price="₹50", course="Desserts", restaurant=restaurant1)
session.add(menuItem5)
session.commit()
menuItem6 = MenuItem(user_id=1, name="Root Beer", description="16oz of refreshing goodness",
price="₹150", course="Beverages", restaurant=restaurant1)
session.add(menuItem6)
session.commit()
menuItem7 = MenuItem(user_id=1, name="Iced Tea", description="with Lemon",
price="₹80", course="Beverages", restaurant=restaurant1)
session.add(menuItem7)
session.commit()
menuItem8 = MenuItem(user_id=1, name="Special Dinner", description="Tandoori chicken, shrimp, lamb kabab, seekh kabab, choice of one curry, rice and choice of one bread",
price="₹500", course="Main Course", restaurant=restaurant1)
session.add(menuItem8)
session.commit()
# Menu for Pin Cuk
restaurant2 = Restaurant(user_id=1, name="Pin Cuk")
session.add(restaurant2)
session.commit()
menuItem1 = MenuItem(user_id=1, name="Chicken Stir Fry", description="With your choice of noodles, vegetables and sauces",
price="₹300", course="Starters", restaurant=restaurant2)
session.add(menuItem1)
session.commit()
menuItem2 = MenuItem(user_id=1, name="Peking Duck", description=" A famous duck dish from Beijing[1] that has been prepared since the imperial era. The meat is prized for its thin, crisp skin, with authentic versions of the dish serving mostly the skin and little meat, sliced in front of the diners by the cook",
price="₹750", course="Main Course", restaurant=restaurant2)
session.add(menuItem2)
session.commit()
menuItem3 = MenuItem(user_id=1, name="Spicy Tuna Roll", description="Seared rare ahi, avocado, edamame, cucumber with wasabi soy sauce ",
price="₹450", course="Main Course", restaurant=restaurant2)
session.add(menuItem3)
session.commit()
menuItem4 = MenuItem(user_id=1, name="Nepali Momo ", description="Steamed dumplings made with vegetables, spices and meat. ",
price="₹200", course="Starters", restaurant=restaurant2)
session.add(menuItem4)
session.commit()
menuItem5 = MenuItem(user_id=1, name="Ramen", description="a Japanese noodle soup dish. It consists of Chinese-style wheat noodles served in a meat- or (occasionally) fish-based broth, often flavored with soy sauce or miso, and uses toppings such as sliced pork, dried seaweed, kamaboko, and green onions.",
price="₹150", course="Main Course", restaurant=restaurant2)
session.add(menuItem5)
session.commit()
# Menu for South Coast Hotel
restaurant3 = Restaurant(user_id=1, name="South Coast Hotel")
session.add(restaurant3)
session.commit()
menuItem1 = MenuItem(user_id=1, name="Mixed Platter", description="Samosa, vegetables, chicken, paneer, shrimp pakora & papadom",
price="₹350", course="Appetizers", restaurant=restaurant3)
session.add(menuItem1)
session.commit()
menuItem2 = MenuItem(user_id=1, name="Fish Tikka", description="Marinated seasonal fish served with choice of soup",
price="₹250", course="Starters", restaurant=restaurant3)
session.add(menuItem2)
session.commit()
menuItem3 = MenuItem(user_id=1, name="Vegetable Green Masala", description="Mixed vegetables in a hot spinach sauce topped with coconut cream",
price="₹300", course="Main Course", restaurant=restaurant3)
session.add(menuItem3)
session.commit()
menuItem4 = MenuItem(user_id=1, name="Bread Basket", description="Naan, Garlic Naan, Cheese Naan",
price="₹150", course="Main Course", restaurant=restaurant3)
session.add(menuItem4)
session.commit()
menuItem5 = MenuItem(user_id=1, name="Gajar Halwa", description="Grated carrots cooked in milk and butter",
price="₹150", course="Desserts", restaurant=restaurant3)
session.add(menuItem5)
session.commit()
# Menu for Barworks Eatery
restaurant4 = Restaurant(user_id=1, name="Barworks Eatery")
session.add(restaurant4)
session.commit()
menuItem1 = MenuItem(user_id=1, name="Tres Leches Cake", description="Rich, luscious sponge cake soaked in sweet milk and topped with vanilla bean whipped cream and strawberries.",
price="₹350", course="Desserts", restaurant=restaurant4)
session.add(menuItem1)
session.commit()
menuItem2 = MenuItem(user_id=1, name="Mushroom Risotto", description="Mushrooms in a creamy risotto",
price="₹250", course="Starters", restaurant=restaurant4)
session.add(menuItem2)
session.commit()
menuItem3 = MenuItem(user_id=1, name="Veggie Burger", description="Made with freshest of ingredients and home grown spices",
price="₹150", course="Starters", restaurant=restaurant4)
session.add(menuItem3)
session.commit()
# Menu for The Mint Leaf Kitchen
restaurant5 = Restaurant(user_id=1, name="The Mint Leaf Kitchen")
session.add(restaurant5)
session.commit()
menuItem1 = MenuItem(user_id=1, name="Shellfish Tower", description="Lobster, shrimp, sea snails, crawfish, stacked into a delicious tower",
price="₹350", course="Starters", restaurant=restaurant5)
session.add(menuItem1)
session.commit()
menuItem2 = MenuItem(user_id=1, name="Choc Full O\' Mint (Smitten\'s Fresh Mint Chip ice cream)",
description="Milk, cream, salt, ..., Liquid nitrogen magic", price="₹350", course="Desserts", restaurant=restaurant5)
session.add(menuItem2)
session.commit()
menuItem3 = MenuItem(user_id=1, name="Aloo Gobi Burrito", description="Vegan goodness. Burrito filled with rice, garbanzo beans, curry sauce, potatoes (aloo), fried cauliflower (gobi) and chutney. Nom Nom",
price="₹350", course="Starters", restaurant=restaurant5)
session.add(menuItem3)
session.commit()
restaurants = session.query(Restaurant).all()
for restaurant in restaurants:
print("Added: " + restaurant.name)