forked from wolin_ck666_999/StuManagerSys
上传文件至「model」
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
from sqlalchemy import *
|
||||||
|
from datetime import datetime
|
||||||
|
from sqlalchemy.orm import declarative_base,sessionmaker
|
||||||
|
|
||||||
|
db_url = "mysql+pymysql://root:123456@127.0.0.1:3306/ai0824_stu?charset=utf8"
|
||||||
|
|
||||||
|
engine = create_engine(db_url, pool_size=100,echo=False)
|
||||||
|
|
||||||
|
Base = declarative_base()
|
||||||
|
|
||||||
|
class Employment(Base):
|
||||||
|
__tablename__ = 's_employment'
|
||||||
|
id = Column(Integer
|
||||||
|
, primary_key=True
|
||||||
|
, autoincrement=True
|
||||||
|
, comment='编号,自增主键')
|
||||||
|
stu_id = Column(String(20)
|
||||||
|
# , ForeingKey('s_student.stu_id')
|
||||||
|
, unique=True
|
||||||
|
, nullable=True
|
||||||
|
, comment='学生学号,唯一')
|
||||||
|
class_name = Column(String(32))
|
||||||
|
company = Column(String(100))
|
||||||
|
salary = Column(Integer
|
||||||
|
, default=0)
|
||||||
|
open_date = Column(DATETIME
|
||||||
|
, default=datetime.now())
|
||||||
|
offer_date = Column(DATETIME
|
||||||
|
, default=datetime.now())
|
||||||
|
work_date = Column(DATETIME
|
||||||
|
, default=datetime.now()
|
||||||
|
, onupdate=datetime.now)
|
||||||
|
is_delete = Column(Integer
|
||||||
|
, default=0
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Session = sessionmaker( bind = engine, autoflush = False, autocommit = False )
|
||||||
|
|
||||||
|
def get_db():
|
||||||
|
db = Session()
|
||||||
|
try:
|
||||||
|
yield db
|
||||||
|
finally:
|
||||||
|
db.close()
|
||||||
Reference in New Issue
Block a user