-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
33 lines (22 loc) · 819 Bytes
/
models.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
from sqlalchemy import Column,Integer,String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, sessionmaker
from sqlalchemy import create_engine
Base = declarative_base()
class Restaurant(Base):
__tablename__ = 'restaurant'
id = Column(Integer, primary_key = True)
restaurant_name = Column(String)
restaurant_address = Column(String)
restaurant_image = Column(String)
#Add a property decorator to serialize information from this database
@property
def serialize(self):
return {
'restaurant_name': self.restaurant_name,
'restaurant_address': self.restaurant_address,
'restaurant_image' : self.restaurant_image,
'id' : self.id
}
engine = create_engine('sqlite:///restaruants.db')
Base.metadata.create_all(engine)