19 lines
764 B
Python
19 lines
764 B
Python
# model/users.py
|
|
# 本文件定义 User 表的结构,映射到 MySQL 数据库
|
|
|
|
from sqlalchemy import Column, Integer, String, DateTime, Float, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from database import Base
|
|
from model.student import Student
|
|
#建立学生考核表模型
|
|
class Score(Base):
|
|
__tablename__ = "student_score" # 表名
|
|
# 字段定义
|
|
score_id = Column(Integer, primary_key=True,autoincrement=True) # 主键,自增,索引
|
|
sid = Column(Integer,ForeignKey("student.sid"),nullable=False) # 用户名,唯一,非空
|
|
exam_num=Column(Integer)#考核次数
|
|
score=Column(Float)#分数
|
|
flag=Column(Integer,default=1)#状态
|
|
#一对多 成绩表
|
|
student=relationship("Student", back_populates="score")
|