master
Raw Download raw file
 1
 2from sqlalchemy import create_engine
 3from sqlalchemy.ext.declarative import declarative_base
 4from sqlalchemy import Column, Integer, String, Enum, Date
 5
 6MYSQL_USER = "admin"
 7MYSQL_PASS = "docker"
 8MYSQL_ADDR = "172.17.0.37"
 9MYSQL_DB   = "test"
10
11engine = create_engine('mysql://%s:%s@%s/%s' % (
12                       MYSQL_USER, 
13                       MYSQL_PASS, 
14                       MYSQL_ADDR,
15                       MYSQL_DB), echo=True)
16Base = declarative_base()
17
18class Appointments(Base):
19  __tablename__ = 'appointments'
20  id         = Column(Integer, primary_key=True)
21  visitor    = Column(String(7))
22  submitter  = Column(String(7))
23  start_date = Column(Date) 
24  end_date   = Column(Date)
25  location   = Column(Enum('upstairs', 'downstiars', name="loacation_type"))
26  status     = Column(Enum('verifed', 'needs tickets', 'needs pnpi', name="status_type"))
27
28  def __init__(self, visitor, submitter, start_date, end_date, location, status):
29    self.visitor = visitor
30    self.submitter = submitter
31    self.start_date = start_date
32    self.end_date = end_date
33    self.location = location
34    self.status = status
35
36Base.metadata.create_all(engine)