-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.py
34 lines (26 loc) · 843 Bytes
/
db.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
#!/usr/bin/env python3
from sqlalchemy import *
from sqlalchemy.orm import sessionmaker
from sqlalchemy.types import *
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('sqlite:///db.sqlite3', echo=True)
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()
class Task(Base):
__tablename__ = 'tasks'
id = Column(Integer, primary_key=True)
chat = Column(Integer)
name = Column(String)
status = Column(String)
dependencies = Column(String)
parents = Column(String)
priority = Column(String)
duedate = Column(Date)
def __repr__(self):
return "<Task(id={}, chat={}, name='{}', status='{}')>".format(
self.id, self.chat, self.name, self.status
)
Base.metadata.create_all(engine)
if __name__ == '__main__':
pass