fix: ensure data directory exists before DB connection in all threads
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
__pycache__/
|
||||
*.pyc
|
||||
config.yaml
|
||||
data/
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user