fix 部分数据库操作没有Commit
This commit is contained in:
parent
c3a0a839c3
commit
99218515ea
@ -8,8 +8,9 @@ Engine = create_engine(f"sqlite:///{settings.CONFIG_PATH}/user.db",
|
|||||||
pool_pre_ping=True,
|
pool_pre_ping=True,
|
||||||
echo=False,
|
echo=False,
|
||||||
poolclass=QueuePool,
|
poolclass=QueuePool,
|
||||||
pool_size=1000,
|
pool_size=1024,
|
||||||
pool_recycle=60 * 10,
|
pool_recycle=600,
|
||||||
|
pool_timeout=180,
|
||||||
max_overflow=0)
|
max_overflow=0)
|
||||||
# 会话工厂
|
# 会话工厂
|
||||||
SessionFactory = sessionmaker(autocommit=False, autoflush=False, bind=Engine)
|
SessionFactory = sessionmaker(autocommit=False, autoflush=False, bind=Engine)
|
||||||
@ -33,7 +34,6 @@ def get_db():
|
|||||||
|
|
||||||
|
|
||||||
class DbOper:
|
class DbOper:
|
||||||
|
|
||||||
_db: Session = None
|
_db: Session = None
|
||||||
|
|
||||||
def __init__(self, db: Session = None):
|
def __init__(self, db: Session = None):
|
||||||
|
@ -130,9 +130,10 @@ class DownloadFiles(Base):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def delete_by_fullpath(db: Session, fullpath: str):
|
def delete_by_fullpath(db: Session, fullpath: str):
|
||||||
return db.query(DownloadFiles).filter(DownloadFiles.fullpath == fullpath,
|
db.query(DownloadFiles).filter(DownloadFiles.fullpath == fullpath,
|
||||||
DownloadFiles.state == 1).update(
|
DownloadFiles.state == 1).update(
|
||||||
{
|
{
|
||||||
"state": 0
|
"state": 0
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
db.commit()
|
||||||
|
@ -23,7 +23,8 @@ class PluginData(Base):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def del_plugin_data_by_key(db: Session, plugin_id: str, key: str):
|
def del_plugin_data_by_key(db: Session, plugin_id: str, key: str):
|
||||||
return db.query(PluginData).filter(PluginData.plugin_id == plugin_id, PluginData.key == key).delete()
|
db.query(PluginData).filter(PluginData.plugin_id == plugin_id, PluginData.key == key).delete()
|
||||||
|
db.commit()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_plugin_data_by_plugin_id(db: Session, plugin_id: str):
|
def get_plugin_data_by_plugin_id(db: Session, plugin_id: str):
|
||||||
|
@ -122,3 +122,4 @@ class TransferHistory(Base):
|
|||||||
"download_hash": download_hash
|
"download_hash": download_hash
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
db.commit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user