diff --git a/app/db/__init__.py b/app/db/__init__.py index acae147d..e18a61e8 100644 --- a/app/db/__init__.py +++ b/app/db/__init__.py @@ -8,8 +8,9 @@ Engine = create_engine(f"sqlite:///{settings.CONFIG_PATH}/user.db", pool_pre_ping=True, echo=False, poolclass=QueuePool, - pool_size=1000, - pool_recycle=60 * 10, + pool_size=1024, + pool_recycle=600, + pool_timeout=180, max_overflow=0) # 会话工厂 SessionFactory = sessionmaker(autocommit=False, autoflush=False, bind=Engine) @@ -33,7 +34,6 @@ def get_db(): class DbOper: - _db: Session = None def __init__(self, db: Session = None): diff --git a/app/db/models/downloadhistory.py b/app/db/models/downloadhistory.py index 6f911902..0999c86b 100644 --- a/app/db/models/downloadhistory.py +++ b/app/db/models/downloadhistory.py @@ -130,9 +130,10 @@ class DownloadFiles(Base): @staticmethod def delete_by_fullpath(db: Session, fullpath: str): - return db.query(DownloadFiles).filter(DownloadFiles.fullpath == fullpath, - DownloadFiles.state == 1).update( + db.query(DownloadFiles).filter(DownloadFiles.fullpath == fullpath, + DownloadFiles.state == 1).update( { "state": 0 } ) + db.commit() diff --git a/app/db/models/plugin.py b/app/db/models/plugin.py index b1717043..e4af5e58 100644 --- a/app/db/models/plugin.py +++ b/app/db/models/plugin.py @@ -23,7 +23,8 @@ class PluginData(Base): @staticmethod 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 def get_plugin_data_by_plugin_id(db: Session, plugin_id: str): diff --git a/app/db/models/transferhistory.py b/app/db/models/transferhistory.py index 86554582..b004877b 100644 --- a/app/db/models/transferhistory.py +++ b/app/db/models/transferhistory.py @@ -122,3 +122,4 @@ class TransferHistory(Base): "download_hash": download_hash } ) + db.commit()