修改数据库8小时未使用,连接关闭的问题

This commit is contained in:
Administrator 2023-04-10 11:07:52 +08:00
parent b9a4e8d6b2
commit 94efcfaab9
3 changed files with 3 additions and 4 deletions

View File

@ -109,6 +109,6 @@ def daily_export(req: QueryParams, db: Session = Depends(get_db)):
file_name = f"{time.strftime('%Y%m%d%H%M%S')}.xlsx"
file_path = f"{temp_path}/{file_name}"
pd.DataFrame(daily_items).to_excel(file_path, index=False)
return {"url": file_path}
return {"url": "/"+file_path}
# return FileResponse(
# path=file_path, headers={'Content-Disposition': f'attachment; filename="{file_name}"'}, filename=file_name)

View File

@ -154,7 +154,7 @@ def refresh_token(token_data: TokenData = Depends(token_data_depend), db: Sessio
return {'token': token}
@router.post("/get_user_by_department", tags=["用户接口"], summary=["根据部门列表获取用户信息"],
@router.post("/get_user_by_department", tags=["用户接口"], summary="根据部门列表获取用户信息",
response_model=UserSchemas.GetUserByDepartmentRes)
def get_user_by_department(body: UserSchemas.GetUserByDepartmentReq, token_data: TokenData = Depends(token_data_depend),
db: Session = Depends(get_db)):
@ -189,7 +189,6 @@ def get_user_can_watch_department(token_data: TokenData = Depends(token_data_dep
if token_data.manage_departments:
for item in token_data.manage_departments.split(","):
can_watch_department.add(int(item))
print(can_watch_department, "can_watch_department")
can_watch_department_list = [department_dict[item] for item in can_watch_department]
return {'item_list': can_watch_department_list, "count": len(can_watch_department_list)}

View File

@ -14,7 +14,7 @@ db = 'daily'
def get_engine():
engine = create_engine(
f"mysql+pymysql://{user}:{password}@{host}/{db}?charset=utf8mb4")
f"mysql+pymysql://{user}:{password}@{host}/{db}?charset=utf8mb4",pool_recycle=3600*4)
return engine