diff --git a/src/zot/schema.py b/src/zot/schema.py index 4a61465..8e6a409 100644 --- a/src/zot/schema.py +++ b/src/zot/schema.py @@ -32,6 +32,11 @@ def create_db(path: str = ":memory:") -> sqlite3.Connection: close it afterward; for ``:memory:`` keep it alive. """ con = sqlite3.connect(path) - con.executescript(_load_sql()) + # One transaction for the whole ~2,500-statement script. executescript + # otherwise autocommits every CREATE/INSERT — thousands of fsyncs — and + # on a file-backed path under disk load that took 15–20 s per fresh + # DB (every prisma test that builds a zotero.sqlite in tmp_path paid + # it; the suite looked hung). As one transaction it is ~instant. + con.executescript("BEGIN;\n" + _load_sql() + "\nCOMMIT;") con.row_factory = sqlite3.Row return con