-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_setup.py
36 lines (27 loc) · 1 KB
/
db_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
import os
import sys
from sqlalchemy import Column, ForeignKey, Integer, Float, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine
Base = declarative_base()
class Sell(Base):
__tablename__ = 'sell'
sell_id = Column(Integer, primary_key=True)
item = Column(String(50), nullable=False)
desc = Column(String(50))
price = Column(Float, nullable=False)
class Ride(Base):
__tablename__ = 'ride'
sell_id = Column(Integer, primary_key=True)
origin = Column(String(50), nullable=False)
destination = Column(String(50), nullable=False)
price = Column(Float, nullable=False)
class Textbook(Base):
__tablename__ = 'textbook'
sell_id = Column(Integer, primary_key=True)
lecture = Column(String(50), nullable=False)
textbook = Column(String(50), nullable=False)
price = Column(Float, nullable=False)
engine = create_engine('sqlite:///bulletin.db')
Base.metadata.create_all(engine)