"""Read-only SQLite connection helpers.""" from __future__ import annotations import sqlite3 from pathlib import Path def connect_readonly(db_path: Path) -> sqlite3.Connection: """Open an immutable, query-only SQLite connection.""" uri = f"file:{db_path.resolve()}?mode=ro&immutable=1" connection = sqlite3.connect(uri, uri=True) connection.execute("PRAGMA query_only = ON") return connection