Files
sqlalchemy_fastapi_demo_1/model/Score.py
T

19 lines
522 B
Python
Raw Normal View History

2026-09-21 19:15:28 +08:00
from sqlalchemy import Column, Integer,ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy_fastapi_demo_1.database import Base
# 成绩表表模型
class Score(Base):
__tablename__ = 'score'
# 联合主键stu_id,exam_order
# 外键关联student
stu_id=Column(Integer,ForeignKey('student.stu_id'),primary_key=True)
# 声明关联student
student=relationship('Student',back_populates='score')
exam_id=Column(Integer,primary_key=True)
score=Column(Integer,nullable=False)