外键
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from scores.database import Base
|
||||
from datetime import datetime
|
||||
from sqlalchemy import DateTime,Column,Integer,String,Float
|
||||
from sqlalchemy import DateTime,Column,Integer,String,Float,ForeignKey
|
||||
class Score(Base):
|
||||
__tablename__='scores'
|
||||
id = Column(Integer
|
||||
@@ -9,9 +9,11 @@ class Score(Base):
|
||||
,comment ='编号'
|
||||
)
|
||||
sid = Column(Integer
|
||||
,ForeignKey('students.id')
|
||||
,comment ='学生ID'
|
||||
)
|
||||
cid = Column(Integer
|
||||
,ForeignKey('classes.id')
|
||||
,comment ='班级ID'
|
||||
)
|
||||
num = Column(Integer
|
||||
@@ -19,6 +21,7 @@ class Score(Base):
|
||||
)
|
||||
score = Column(Integer,nullable = False)
|
||||
tsub = Column(String(100)
|
||||
, ForeignKey('subject.id')
|
||||
,nullable = False
|
||||
)
|
||||
create_date = Column(DateTime
|
||||
|
||||
Reference in New Issue
Block a user