This commit is contained in:
jxxghp
2023-10-18 19:26:21 +08:00
parent 2e4536edb6
commit 3d34c26731
55 changed files with 142 additions and 137 deletions

View File

@ -45,4 +45,4 @@ def update_db():
alembic_cfg.set_main_option('sqlalchemy.url', f"sqlite:///{db_location}")
upgrade(alembic_cfg, 'head')
except Exception as e:
logger.error(f'数据库更新失败:{e}')
logger.error(f'数据库更新失败:{str(e)}')

View File

@ -16,7 +16,12 @@ def db_persist(func):
def wrapper(*args, **kwargs):
with DBLock:
db: Session = kwargs.get("db") or args[1]
db: Session = kwargs.get("db")
if not db:
for arg in args:
if isinstance(arg, Session):
db = arg
break
try:
if db:
db.close()