-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.py
More file actions
41 lines (30 loc) · 1.09 KB
/
model.py
File metadata and controls
41 lines (30 loc) · 1.09 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
41
import peewee
import datetime
sqlite_db = peewee.SqliteDatabase('bot_db', pragmas={
'journal_mode': "wal",
'cache_size': -1024 * 64
})
class BaseModel(peewee.Model):
class Meta:
database = sqlite_db
order_by = 'id'
class User(BaseModel):
id = peewee.BigIntegerField(primary_key=True, unique=True)
telegram_id = peewee.BigIntegerField(unique=True)
name = peewee.CharField(max_length=70)
lessons_quant = peewee.IntegerField(default=0)
request_date = peewee.DateTimeField(default=datetime.datetime.now)
confirmed = peewee.BooleanField(default=False)
blocked = peewee.BooleanField(default=False)
block_date = peewee.DateTimeField(default=datetime.datetime.now)
class Meta:
db_table = 'users'
class Notification(BaseModel):
user = peewee.ForeignKeyField(User)
notification_date = peewee.DateTimeField()
performed = peewee.BooleanField(default=False)
canceled = peewee.BooleanField(default=False)
class Meta:
db_table = 'notifications'
if __name__ == "__main__":
sqlite_db.create_tables([User, Notification])