test一轮完成的版本

This commit is contained in:
2026-09-12 20:55:36 +08:00
parent 004fd75a46
commit c4ae803a34
8 changed files with 50 additions and 68 deletions
+9 -9
View File
@@ -14,16 +14,16 @@ class Advisor(Base):
__tablename__ = "advisor"
id = Column(Integer, primary_key=True, autoincrement=True, comment="顾问编号")
name = Column(String(50), nullable=False, index=True, comment="顾问姓名")
gender = Column(String(8), comment="性别")
phone = Column(String(20), index=True, comment="手机号")
email = Column(String(64), comment="邮箱")
region = Column(String(64), comment="负责区域/招生渠道")
adv_id = Column(Integer, primary_key=True, autoincrement=True, comment="顾问编号")
adv_name = Column(String(50), nullable=False, index=True, comment="顾问姓名")
adv_gender = Column(String(8), comment="性别")
adv_phone = Column(String(20), index=True, comment="手机号")
adv_email = Column(String(64), comment="邮箱")
adv_region = Column(String(64), comment="负责区域/招生渠道")
is_deleted = Column(SmallInteger,nullable=False, default=0,server_default="0",
index=True,comment="1=已删除",)
students = relationship("Student",primaryjoin="and_(Advisor.id == Student.advisor_id, Student.is_deleted == 0)",
foreign_keys="Student.advisor_id",viewonly=True,lazy="selectin",)
#下面的内容临时注释,在main导入时,SQLAlchemy 在配置映射时就会报错,错误大概是:ArgumentError: Could not locate any relevant foreign key columns for primary join condition ...
# students = relationship("Student",primaryjoin="and_(Advisor.id == stu_id, Student.is_deleted == 0)",
# foreign_keys="stu_id",viewonly=True,lazy="selectin",)
+6 -8
View File
@@ -1,10 +1,8 @@
#班级管理 熊浩钦
from sqlalchemy import Column, Integer, DateTime
from sqlalchemy.orm import relationship
from sqlalchemy import Column, Integer, Date, String
from database import Base
class WlClass(Base):
__tablename__ = "wl_class"
class_id = Column(Integer, primary_key=True, index=True, comment="班级编号")
start_time = Column(DateTime, comment="开课时间")
is_deleted = Column(Integer, default=0, comment="逻辑删除标记(0正常,1已删)")
class Class_(Base):
__tablename__ = "class_info"
class_id = Column(Integer, primary_key=True, autoincrement=True, comment="班级编号")
start_time = Column(Date, comment="开课时间")
+2 -19
View File
@@ -1,19 +1,12 @@
#学生就业 赵康宁
from sqlalchemy import *
from sqlalchemy.orm import *
db_url = "sqlalchemy+pymysql://root:123456@localhost/Student"
engine = create_engine(db_url, pool_size=8)
Base = declarative_base()
emp_stu = Table('emp_stu',
Base.metadata,
Column('stu_id', Integer, ForeignKey('stu_id'), primary_key=True))
class emp(Base):
class Emp(Base):
__tablename__ = "wl_emp"
stu_id = Column(Integer, primary_key=True, autoincrement=True)
emp_open_time = Column(DateTime, default="2026-11-30 18:18:18")
offer_time = Column(DateTime, default=func.now())
company_name = Column(String(100), nullable=False)
@@ -24,13 +17,3 @@ class emp(Base):
def __repr__(self):
pass
SessionLocal = sessionmaker(bind=engine)
db_session = SessionLocal()
Base.metadata.create_all(engine)
"""
数据增删改查
"""
db_session.close()
+3 -5
View File
@@ -1,8 +1,7 @@
#学生考核成绩 圣国伟
from sqlalchemy import Column, Integer, Float
from sqlalchemy import Column, Integer, Float
from database import Base
class StudentScore(Base):
class Score(Base):
__tablename__ = "student_score"
stu_id = Column(Integer, primary_key=True, comment="学生编号")
@@ -11,4 +10,3 @@ class StudentScore(Base):
+2 -2
View File
@@ -10,7 +10,7 @@ class Student(Base):
stu_id = Column(Integer, primary_key=True, autoincrement=True, comment='内部主键')
# ---------- 业务学号(对外,按规则生成)----------
stu_no = Column(String(20), unique=True, nullable=False, index=True, comment='学号')
# class_id = Column(Integer, ForeignKey('wl_class.id'), nullable=True, comment='班级ID')
class_id = Column(Integer, ForeignKey('class_info.class_id'), nullable=True, comment='班级ID')
stu_name = Column(String(30), nullable=True, comment='学生姓名')
native_place = Column(String(50), nullable=True, comment='籍贯')
graduate_school=Column(String(128), nullable=True, comment='毕业学校')
@@ -18,7 +18,7 @@ class Student(Base):
in_time= Column(Date, nullable=True, comment='入学时间')
out_time= Column(Date, nullable=True, comment='毕业时间')
edu= Column(String(32), nullable=True, comment='学历')
# advisor_id = Column(Integer, ForeignKey('wl_advisor.id'), nullable=True, comment='顾问ID')
advisor_id = Column(Integer, ForeignKey('advisor.adv_id'), nullable=True, comment='顾问ID')
stu_age = Column(Integer, nullable=True, comment='年龄')
stu_gender = Column(String(8), nullable=True, comment='性别')
+1 -2
View File
@@ -1,11 +1,10 @@
#老师管理模块 刘盼
from sqlalchemy import create_engine
from database import Base, engine
class Teacher(Base):
__tablename__ = 'wl_teacher'
t_id = Column(Integer, primary_key=True, autoincrement=True)
teacher_no = Column(String(20), unique=True, nullable=False)
t_no = Column(String(20), unique=True, nullable=False)
t_name = Column(String(50), nullable=False)
t_phone = Column(String(20), unique=True, nullable=True)
t_email = Column(String(20), unique=False)