曾凯成绩数据库模型
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
from sqlalchemy import *
|
||||
from core.database import Base
|
||||
from datetime import datetime,date
|
||||
class Score(Base):
|
||||
__tablename__ = "score_info_detail"
|
||||
id = Column(Integer
|
||||
, primary_key=True
|
||||
,autoincrement=True
|
||||
,comment="成绩表序号,自增主键"
|
||||
)
|
||||
student_id = Column(Integer
|
||||
,ForeignKey("student.id")
|
||||
,nullable=False
|
||||
,comment="学生学号"
|
||||
)
|
||||
score = Column(DECIMAL(4,1)
|
||||
,CheckConstraint("score between 0 and 100")
|
||||
)
|
||||
exam_seq= Column(Integer
|
||||
, nullable=False
|
||||
,comment="考试序次")
|
||||
__table_args__ = (
|
||||
UniqueConstraint("student_id"
|
||||
, "exam_seq"
|
||||
, name="uk_student_exam_seq"),
|
||||
)#学生id和学生姓名应为联合唯一,即一个学生一次考试只能有一个分数
|
||||
exam_date=Column(Date
|
||||
,default=date.today
|
||||
,comment="考试日期"
|
||||
)
|
||||
created_at=Column(DateTime
|
||||
,default=datetime.now
|
||||
,comment="创建时间"
|
||||
)
|
||||
updated_at=Column(DateTime
|
||||
,default=datetime.now
|
||||
,onupdate=datetime.now
|
||||
,comment="更新时间"
|
||||
)
|
||||
remark=Column(String(225)
|
||||
,comment="备注说明"
|
||||
)
|
||||
is_deleted=Column(Integer
|
||||
,default=0
|
||||
,comment="逻辑删除标记:未删除0,已删除1"
|
||||
)
|
||||
Reference in New Issue
Block a user