This commit is contained in:
team3
2026-09-22 13:50:58 +02:00
parent 23d4b08d4f
commit 139663819c

View File

@@ -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 @contextmanager
def connect(): def connect():
DB_PATH.parent.mkdir(parents=True, exist_ok=True) 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 conn.row_factory = sqlite3.Row
try: try:
yield conn yield conn
@@ -37,6 +39,7 @@ def connect():
def init(): def init():
with connect() as conn: with connect() as conn:
conn.executescript(SCHEMA) conn.executescript(SCHEMA)
conn.execute("PRAGMA journal_mode=WAL")
def cursor(conn): def cursor(conn):