统计分析模块

This commit is contained in:
2026-09-22 19:00:51 +08:00
parent 7ec50c3aea
commit 0a1a7eec16
11 changed files with 577 additions and 1 deletions
+20
View File
@@ -0,0 +1,20 @@
from sqlalchemy import *
from sqlalchemy.orm import declarative_base,sessionmaker
db_url = "mysql+pymysql://root:123456@127.0.0.1:3306/student?charset=utf8mb4" #创建连接对象
engine = create_engine(db_url) #与数据库进行连接
Base = declarative_base() # 执行函数,返回一个基类
Session = sessionmaker(bind=engine
,autoflush=False
,autocommit = False
)
def get_db():
db = Session()
try:
yield db
finally:
db.close()