from sqlalchemy import Column, Integer, String, DateTime, Float, Date, ForeignKey from sqlalchemy.orm import relationship from database import Base class Student(Base): __tablename__ = "student" sid=Column(Integer,primary_key=True,autoincrement=True) cid =Column(Integer, ForeignKey("student_class.cid"),nullable=False)#班级编号,外键关联班级表 name=Column(String(30),nullable=False)#学生姓名,字符串形式,不能为空值(必填) address=Column(String(50),nullable=False)#籍贯,字符串形式,不能为空值(必填) school=Column(String(50),nullable=False)#毕业院校,字符串形式,不能为空值(必填) major=Column(String(50),nullable=False)#专业,字符串形式,不能为空值(必填) start_time=Column(Date,nullable=False)#入学时间,字符串形式,不能为空值(必填) end_time=Column(Date,nullable=True)#毕业时间,字符串形式,可以为空值(未毕业学生) education=Column(String(20),nullable=False)#学历 ,字符串形式,不能为空值(必填) consultant_id=Column(Integer,nullable=False)#顾问编号,整数 gender=Column(String(3),nullable=False)#性别,字符串 age=Column(Integer,nullable=False)#年龄 flag=Column(Integer,nullable=False)#逻辑删除,当值为1是保留,当值为0时删除 score=relationship("Score",back_populates="student") work=relationship("Work",back_populates="student") classes=relationship("Class",back_populates="student")