-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase_setup.py
executable file
·43 lines (37 loc) · 1.25 KB
/
database_setup.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
import sys
from sqlalchemy import Column, ForeignKey, Integer, String, Date, DateTime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine
Base = declarative_base()
class Hotel(Base):
"""
Hotel store all the information we need in the datbase for hotels
"""
__tablename__ = 'hotel'
id = Column(Integer, primary_key=True)
name = Column(String(100), nullable=False)
class Price(Base):
"""
Prices store all price information we need in the database
"""
__tablename__ = 'price'
id = Column(Integer, primary_key=True)
hotel_id = Column(Integer, ForeignKey('hotel.id'))
hotel = relationship(Hotel)
date = Column(Date, nullable=False)
price = Column(Integer)
class Flight(Base):
__tablename__ = 'flight'
id = Column(Integer, primary_key=True)
start_ariport = Column(String)
start_searched_airport = Column(String)
end_airport = Column(String)
end_searched_airport = Column(String)
departure_time = Column(DateTime)
arrival_time = Column(DateTime)
price = Column(Integer)
link = Column(String)
airline = Column(String)
engine = create_engine('sqlite:///db.db')
Base.metadata.create_all(engine)