diff --git a/core/database.py b/core/database.py index ae95c99..cb3bab3 100644 --- a/core/database.py +++ b/core/database.py @@ -17,7 +17,7 @@ IP:localhost from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker,declarative_base -from .config import ( +from core.config import ( database_connect_user, database_connect_password, database_connect_ip, diff --git a/models/student.py b/models/student.py index e69de29..990a693 100644 --- a/models/student.py +++ b/models/student.py @@ -0,0 +1,45 @@ +from core.database import Base +from sqlalchemy import * +from datetime import datetime + +class Student(Base): + __tablename__ = 'student_info_detail' + id = Column(Integer + , primary_key=True + , autoincrement=True + , comment = '学生编号,自增主键' + ) + student_no = Column(VARCHAR(50) + , unique = True) + student_name = Column(VARCHAR(50)) + class_id = Column(Integer + ,foreign_key = 'class_info_detail.id' + )#外键约束 班级表的主键id,存在这个班级,学生表才可以输入 + consultant_id = Column(Integer + ,nullable = True + ,foreign_key = 'consultant_info_detail.id' + )#外键约束 顾问表的主键id,存在这个顾问,才可以写入,允许为空 + native_place = Column(VARCHAR(100) + ,nullable = True) + graduation_school = Column(VARCHAR(100) + ,nullable = True) + major = Column(VARCHAR(100) + ,nullable = True) + enrollment_date = Column(Date + ,nullable = False)#入学时间必填 + graduation_date = Column(Date, + nullable = True)#毕业时间可以为空 + education = Column(VARCHAR(50) + ,nullable = True)#学历可以为空 + age = Column(Integer + ,nullable = False) + gender = Column(VARCHAR(10) + ,nullable = False) + create_at = Column(DATETIME + ,default = datetime.now) + update_at = Column(DATETIME + ,default = datetime.now + ,onupdate = datetime.now) + is_deleted = Column(Integer + ,default = 0)#逻辑删除,默认为0,为1则表示已删除 +