加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
models.py 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
captain3 提交于 2022-04-24 11:04 . add files
from exts import db
from datetime import datetime
class EmailCaptchaModel(db.Model):
__tablename__ = "email_captcha"
id = db.Column(db.Integer,primary_key=True,autoincrement=True)
email = db.Column(db.String(100),unique=True)
captcha = db.Column(db.String(10))
create_time = db.Column(db.DateTime,default=datetime.now)
class UserModel(db.Model):
__tablename__ = "user"
id = db.Column(db.Integer,primary_key=True,autoincrement=True)
username = db.Column(db.String(200),unique=True)
email = db.Column(db.String(100),unique=True)
password = db.Column(db.String(200))
join_time = db.Column(db.DateTime,default=datetime.now)
# 问题模块
class QuestionModel(db.Model):
__tablename__ = "question"
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
title = db.Column(db.String(200))
content = db.Column(db.Text)
create_time = db.Column(db.DateTime,default=datetime.now)
author_id = db.Column(db.Integer,db.ForeignKey("user.id"))
author = db.relationship("UserModel",backref="questions")
# 问答模型
class AnswerModel(db.Model):
__tablename__ = "answer"
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
content = db.Column(db.Text)
create_time = db.Column(db.DateTime,default=datetime.now)
question_id = db.Column(db.Integer,db.ForeignKey("question.id"))
author_id = db.Column(db.Integer, db.ForeignKey("user.id"))
question = db.relationship("QuestionModel",backref=db.backref("answers",order_by=create_time.desc()))
author = db.relationship("UserModel",backref="answers")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化