From 920173c8faaab5a65459ce176d36812bac6feb08 Mon Sep 17 00:00:00 2001 From: Yuki-Asuuna <10174503104@stu.ecnu.edu.cn> Date: Fri, 25 Feb 2022 21:22:48 +0800 Subject: =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0b=E7=AB=99=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8b74e3a286901379b8337e33d1b581524cb80d97 --- ATRI/database/models.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ATRI/database/models.py (limited to 'ATRI/database/models.py') diff --git a/ATRI/database/models.py b/ATRI/database/models.py new file mode 100644 index 0000000..b3953df --- /dev/null +++ b/ATRI/database/models.py @@ -0,0 +1,22 @@ +""" + 定义SQLITE数据库的关系模式(表) + 数据库采用了tortoise orm,可以很好地支持异步 +""" + +from tortoise.models import Model +from tortoise import fields +from datetime import datetime + +# b站订阅表 +class Subscription(Model): + uid = fields.IntField(pk=True) # up的uid + groupid = fields.IntField() # 群号 + nickname = fields.TextField(null=True) # 订阅up的名称 + last_update = fields.DatetimeField( + default=datetime.fromordinal(1) + ) # 上一条动态更新时间 默认0001-01-01 00:00:00 + + def __str__(self): + return "[{nickname}|{uid}|{groupid}]".format( + nickname=self.nickname, uid=self.uid, groupid=self.groupid + ) -- cgit v1.2.3