37 lines
962 B
Python
37 lines
962 B
Python
#学生就业 赵康宁
|
|||
|
|
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):
|
||
|
|
__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)
|
||
|
|
salary = Column(Integer, nullable=False, default=15000)
|
||
|
|
|
||
|
|
student = relationship("wl_student", back_populates="wl_emp")
|
||
|
|
|
||
|
|
def __repr__(self):
|
||
|
|
pass
|
||
|
|
|
||
|
|
|
||
|
|
SessionLocal = sessionmaker(bind=engine)
|
||
|
|
db_session = SessionLocal()
|
||
|
|
Base.metadata.create_all(engine)
|
||
|
|
|
||
|
|
"""
|
||
|
|
数据增删改查
|
||
|
|
"""
|
||
|
|
db_session.close()
|
||
|
|
|