fix 偿试减少会话使用

This commit is contained in:
jxxghp
2023-09-01 15:00:27 +08:00
parent 4dba739d54
commit ac1dcbed3c
5 changed files with 13 additions and 11 deletions

View File

@ -14,6 +14,9 @@ Engine = create_engine(f"sqlite:///{settings.CONFIG_PATH}/user.db",
# 数据库会话
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=Engine)
# 全局使用的数据库会话
GlobalDB = SessionLocal()
def get_db():
"""
@ -37,7 +40,7 @@ class DbOper:
if db:
self._db = db
else:
self._db = SessionLocal()
self._db = GlobalDB
def __del__(self):
if self._db: