fix: ensure data directory exists before DB connection in all threads

This commit is contained in:
2026-07-15 18:18:24 +08:00
parent 54c4bf00fb
commit d42022cc2e
2 changed files with 2 additions and 0 deletions

View File

@@ -49,6 +49,7 @@ def init_db():
def _get_conn() -> sqlite3.Connection:
if not hasattr(_local, "conn") or _local.conn is None:
DB_PATH.parent.mkdir(parents=True, exist_ok=True)
_local.conn = sqlite3.connect(str(DB_PATH), timeout=10)
_local.conn.execute("PRAGMA journal_mode=WAL")
_local.conn.execute("PRAGMA busy_timeout=5000")