diff --git a/backend/app/db.py b/backend/app/db.py index c48d2ce..d844d5b 100644 --- a/backend/app/db.py +++ b/backend/app/db.py @@ -22,10 +22,12 @@ CREATE INDEX IF NOT EXISTS items_seq ON items(seq); """ +# Große Datei-Uploads halten die Datenbank sekundenlang. WAL lässt Leser derweil durch, +# Schreiber warten bis zu 60 s statt mit "database is locked" abzubrechen. @contextmanager def connect(): DB_PATH.parent.mkdir(parents=True, exist_ok=True) - conn = sqlite3.connect(DB_PATH) + conn = sqlite3.connect(DB_PATH, timeout=60) conn.row_factory = sqlite3.Row try: yield conn @@ -37,6 +39,7 @@ def connect(): def init(): with connect() as conn: conn.executescript(SCHEMA) + conn.execute("PRAGMA journal_mode=WAL") def cursor(conn):