-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
52 lines (41 loc) · 1.41 KB
/
models.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
import peewee
import pymysql
from peewee import *
db = MySQLDatabase('spider',
host="127.0.0.1",
user="root",
password="123456",
port=3306,
charset="utf8mb4"
)
class BaseModel(Model):
class Meta:
database = db
class Topic(BaseModel):
title = CharField() # 题目
content = TextField(default="") # 内容
id = IntegerField(primary_key=True) # ID
author = CharField() # 作者
creat_time = DateTimeField() # 创建时间
answer_num = IntegerField(default=0) # 回复数
click_num = IntegerField(default=0) # 点击数
parise_num = IntegerField(default=0) # 点赞数
jtl = FloatField(default=0.0) # 结贴率
score = IntegerField(default=0) # 赏分
status = CharField() # 状态
last_time = DateTimeField() # 最后回复时间
class Answer(BaseModel):
topic_id = IntegerField()
author = CharField()
content = TextField(default="")
creat_time = DateTimeField()
parise_num = IntegerField(default=0)
class Author(BaseModel):
name = CharField(max_length=30)
id = CharField(primary_key=True)
desc = TextField(null=True)
follower_num = IntegerField(default=0) # 粉丝数
following_num = IntegerField(default=0) # 关注数
if __name__ == "__main__":
# 建表
db.create_tables([Topic, Author, Answer])