Best-effort parse for JSON object metadata fields stored in SQLite.
(raw: Any)
| 50 | because the GUI polls task state while a background pull is committing. |
| 51 | Both pragmas are best-effort: WAL is unavailable on some filesystems and for |
| 52 | in-memory databases, and failing to set it must not break plain CRUD. |
| 53 | """ |
| 54 | conn = sqlite3.connect(DB_PATH, timeout=_BUSY_TIMEOUT_MS / 1000.0) |
| 55 | conn.row_factory = sqlite3.Row |
| 56 | try: |
| 57 | conn.execute(f"PRAGMA busy_timeout = {_BUSY_TIMEOUT_MS}") |
| 58 | conn.execute("PRAGMA journal_mode = WAL") |
| 59 | conn.execute("PRAGMA synchronous = NORMAL") |
| 60 | except sqlite3.Error: |
| 61 | pass |
| 62 | return conn |
| 63 | |
| 64 | |
| 65 | @contextmanager |
| 66 | def connection() -> Iterator[sqlite3.Connection]: |
| 67 | """Connection scope that always closes, even when the body raises. |
no outgoing calls
no test coverage detected