SQLite 开启 WAL 模式 + busy_timeout 解决并行扫描写入锁冲突

This commit is contained in:
2569718930@qq.com
2026-05-25 16:53:20 +08:00
parent 045121a457
commit 75e6f58a56
5 changed files with 106 additions and 63 deletions
+4 -1
View File
@@ -27,7 +27,10 @@ class DBManager:
return raw
def _get_connection(self):
return sqlite3.connect(self.db_path)
conn = sqlite3.connect(self.db_path, timeout=10)
conn.execute("PRAGMA journal_mode=WAL")
conn.execute("PRAGMA busy_timeout=5000")
return conn
def _init_cache_key(self) -> str:
return os.path.abspath(self.db_path)