MuSProt / backend /app /protein /database.py
wenruifan's picture
Deploy MuSProt React and FastAPI application
3993320
Raw
History Blame Contribute Delete
416 Bytes
"""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