-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.py
48 lines (31 loc) · 1.22 KB
/
database.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
44
45
46
47
48
from sqlalchemy import create_engine
engine = create_engine('sqlite:///database', echo=False)
from sqlalchemy.orm import sessionmaker
Session = sessionmaker(bind=engine)
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
from sqlalchemy import Column, Integer, String, Boolean
class Link(Base):
__tablename__ = 'link'
recurring_id = Column(String, primary_key=True, autoincrement=False)
wa_id = Column(Integer)
ended = Column(Boolean, default=False)
def __repr__(self):
return "<Link(recurring_id='%s', wa_id=%d)>" % (
self.recurring_id, self.wa_id)
class Status(Base):
__tablename__ = 'status'
id = Column(Integer, primary_key=True)
skip = Column(Integer)
complete = Column(Boolean)
def __repr__(self):
return "<Status(id=%d, skip=%d, complete=%b)>" % (
self.id, self.skip, self.complete)
class Payment(Base):
__tablename__ = 'payment'
pp_transaction_id = Column(String, primary_key=True, autoincrement=False)
wa_payment_id = Column(String)
def __repr__(self):
return "<Payment(pp_transaction_id=%s, wa_payment_id=%s)>"
Base.metadata.create_all(engine)
session = Session()