-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
40 lines (32 loc) · 1.21 KB
/
db.py
File metadata and controls
40 lines (32 loc) · 1.21 KB
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
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
base = declarative_base()
class User(base):
__tablename__ = "users"
ID = Column(Integer, primary_key=True)
chat_id = Column(Integer, unique=True, nullable=False)
def __init__(self, chat_id):
self.chat_id = chat_id
class TemplateTotalUse(base): # record total use
__tablename__ = "templates_use"
ID = Column(Integer, primary_key=True)
template_id = Column(Integer, unique=True, nullable=False)
use = Column(Integer, default=1)
def __init__(self, template_id):
self.template_id = template_id
class Memes(base):
__tablename__ = "memes"
ID = Column(Integer, primary_key=True)
chat_id = Column(Integer, nullable=False)
template_id = Column(Integer, nullable=False)
text1 = Column(String)
text2 = Column(String)
text3 = Column(String)
text4 = Column(String)
def __init__(self, chat_id, template_id, text1=None, text2=None, text3=None, text4=None):
self.chat_id = chat_id
self.template_id = template_id
self.text1 = text1
self.text2 = text2
self.text3 = text3
self.text4 = text4