Exemple #1
0
class Grade(BaseNodel):
    #成绩表
    __tablename__ = 'grade'

    grade = models.Column(models.Float, default=0)
    course_id = models.Column(models.Integer, models.ForeignKey("course.id"))
    student_id = models.Column(models.Integer, models.ForeignKey("students.id"))#外键关系是学生
Exemple #2
0
class Grade(BaseModel):
    """
    成绩表
    课程,学员关联此表
    """
    __tablename__ = "grade"
    grade = models.Column(models.Float, default=0)
    course_id = models.Column(models.Integer, models.ForeignKey("course.id"))
    student_id = models.Column(models.Integer, models.ForeignKey("students.id"))
Exemple #3
0
class Attendance(BaseNodel):
    #考勤表
    __tablename__ = 'attendance'

    att_time = models.Column(models.Date)
    status = models.Column(models.Integer, default=1)  # 0 迟到  1 正常出勤  2 早退  3 请假  4 旷课
    student_id = models.Column(models.Integer, models.ForeignKey("students.id"))#外键字段是学生表
Exemple #4
0
class Teacher(BaseNodel):
    #老师表
    __tablename__ = 'teacher'

    name = models.Column(models.String(32))
    age = models.Column(models.Integer)
    gender = models.Column(models.Integer)  # 0 男 1女 -1 unknown
    course_id = models.Column(models.Integer, models.ForeignKey("course.id"))#外键字段的搭建对应的课程表
Exemple #5
0
class Attendance(BaseModel):
    """
    考勤表,记录是否请假
    学员
    """
    __tablename__ = "attendance"
    att_time = models.Column(models.Date)
    status = models.Column(models.Integer,default = 1) #0 迟到  1 正常出勤  2 早退  3 请假  4 旷课
    student_id = models.Column(models.Integer, models.ForeignKey("students.id"))
Exemple #6
0
class Teachers(BaseModel):
    """
    教师
    老师与课程是多对一关系
    """
    __tablename__ = "teachers"
    name = models.Column(models.String(32))
    age = models.Column(models.Integer)
    gender = models.Column(models.Integer,default = 3)  # 0 男 1女 -1 unknown
    course_id = models.Column(models.Integer, models.ForeignKey("course.id")) #教师多对一 映射表是课程
Exemple #7
0

class Students(BaseModel):
    """
    学员表
    """
    __tablename__ = "students"
    name = models.Column(models.String(32))
    age = models.Column(models.Integer)
    gender = models.Column(models.Integer,default = 13) #0 男 1女 -1 unknown


Stu_Cou = models.Table(
    "stu_cou",
    models.Column("id", models.Integer, primary_key=True, autoincrement=True),
    models.Column("course_id", models.Integer, models.ForeignKey("course.id")),
    models.Column("student_id", models.Integer, models.ForeignKey("students.id"))
)


class Course(BaseModel):
    """
    课程表
    """
    __tablename__ = "course"
    label = models.Column(models.String(32))
    description = models.Column(models.Text)

    to_teacher = models.relationship(
        "Teachers",  #映射表
        backref = "to_course_data", #反向映射字段,反向映射表通过该字段查询当前表内容