-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
92 lines (75 loc) · 1.84 KB
/
__init__.py
File metadata and controls
92 lines (75 loc) · 1.84 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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
from loguru import logger
from peewee import (
MySQLDatabase,
CompositeKey,
Model,
CharField,
TextField,
DateTimeField,
IntegerField,
BooleanField,
)
from playhouse.shortcuts import ReconnectMixin
from src.config import settings
class ReconnectMySQLDatabase(ReconnectMixin, MySQLDatabase):
pass
db = ReconnectMySQLDatabase(
database=settings.database,
host=settings.database_host,
port=settings.database_port,
user=settings.database_user,
password=settings.database_passwd,
charset="utf8mb4",
)
if not db.connect():
logger.error("Database connection failed")
raise ValueError("Database connection failed")
class Anno(Model):
language = CharField()
summary = TextField()
details = TextField()
start = DateTimeField()
end = DateTimeField()
class Meta:
database = db
table_name = "anno"
class Plan(Model):
plan_index = IntegerField()
type_id = CharField()
plan_id = CharField()
title = TextField()
price = CharField()
original_price = CharField()
popular = IntegerField()
available = BooleanField()
afdian_id = CharField()
yimapay_id = CharField()
class Meta:
database = db
table_name = "plan"
class Project(Model):
type_id = CharField()
proj_index = IntegerField()
rid = CharField()
name = CharField()
desc = TextField()
image = TextField()
url = TextField()
platform = TextField()
download = BooleanField()
available = BooleanField()
class Meta:
database = db
table_name = "project"
class ICP(Model):
domain = CharField()
beian = CharField()
entity = CharField()
url = CharField()
class Meta:
database = db
table_name = "icp"
Anno.create_table()
Plan.create_table()
Project.create_table()
ICP.create_table()