-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmenus.py
More file actions
89 lines (64 loc) · 2.77 KB
/
Copy pathmenus.py
File metadata and controls
89 lines (64 loc) · 2.77 KB
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
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from database_setup import Restaurant, Base, MenuItem, User
engine = create_engine('sqlite:///restaurantmenu.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="admin", email="vinukonda.sruthi@gmail.com")
session.add(User1)
session.commit()
# Menu for Rajula's Kitchen
restaurant1 = Restaurant(name="Rajula's Kitchen", user_id="1")
session.add(restaurant1)
session.commit()
menuItem1 = MenuItem(name="Masala Dosa",
description="Crepe made from rice"
"batter and black lentils.",
price="$2.99", restaurant=restaurant1, user_id=1)
session.add(menuItem1)
session.commit()
menuItem2 = MenuItem(name="Sambar Idly",
description=" Rice cake with"
"lentil-based vegetable stew.",
price="$7.50", restaurant=restaurant1, user_id=1)
session.add(menuItem2)
session.commit()
menuItem3 = MenuItem(name="Pongal",
description="South indian porridge"
"made with rice and yellow moong lentils.",
price="$5.50", restaurant=restaurant1, user_id=1)
session.add(menuItem3)
session.commit()
# Menu for Biryani Pot
restaurant2 = Restaurant(name="Biryani Pot")
session.add(restaurant2)
session.commit()
menuItem1 = MenuItem(name="Veg Biryani",
description="Rice dish layered with vegetables.",
price="$7.99", restaurant=restaurant2)
session.add(menuItem1)
session.commit()
menuItem2 = MenuItem(name="Avakai Biryani",
description="Rice dish"
"layered with vegetables and mango pickle.",
price="$25", restaurant=restaurant2)
session.add(menuItem2)
session.commit()
menuItem3 = MenuItem(name="Gongura Biryani",
description="Rice dish with veggies and chutney"
"made with Sorrel leaves.",
price="$15", restaurant=restaurant2)
session.add(menuItem3)
session.commit()
print "Added menu items!"