19 lines
496 B
Python
19 lines
496 B
Python
from sqlalchemy import Column, Integer,ForeignKey
|
|||
|
|
from sqlalchemy.orm import relationship
|
||
|
|
from 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)
|
||
|
|
|
||
|
|
|
||
|
|
|