-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dbmodels.py
79 lines (62 loc) · 2.01 KB
/
dbmodels.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from peewee import *
import config
import datetime
db = SqliteDatabase(config.DATABASE["filename"])
class BaseModel(Model):
class Meta:
database = db
legacy_table_names=False
class User(BaseModel):
class Meta:
table_name = 'users'
chat_id = IntegerField()
username = TextField(default='noname')
started_date = DateField()
last_check = DateTimeField(default=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
language = CharField(max_length=10, default='eng')
class GlobalStats(BaseModel):
class Meta:
table_name = 'global_stats'
cases = IntegerField()
todayCases = IntegerField()
deaths = IntegerField()
todayDeaths = IntegerField()
recovered = IntegerField()
todayRecovered = IntegerField()
active = IntegerField()
updated = DateTimeField()
class CountryStats(BaseModel):
class Meta:
table_name = 'countries_stats'
country = CharField(max_length=25)
cases = IntegerField()
todayCases = IntegerField()
deaths = IntegerField()
todayDeaths = IntegerField()
recovered = IntegerField()
todayRecovered = IntegerField()
critical = IntegerField()
active = IntegerField()
casesPerOneMillion = IntegerField()
deathsPerOneMillion = IntegerField()
tests = IntegerField()
updated = DateTimeField()
class Notification(BaseModel):
class Meta:
table_name = 'notifications'
user_id = ForeignKeyField(User, backref='notifs')
username = TextField(default='noname')
country = CharField(max_length=25)
last_check = DateTimeField(default=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
added = DateTimeField(default=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
# class VaccineData(BaseModel):
# class Meta:
# table_name = 'vaccinedata'
#
# candidate = CharField(max_length=25)
# mechanism = TextField()
# sponsors = TextField()
# trialPhase = TextField()
# institutions = TextField()
db.connect()
db.create_tables([User, GlobalStats, CountryStats, Notification])