"""SQLite data store for Waxwing — cf-core migrations + WAL mode.""" from __future__ import annotations import sqlite3 from pathlib import Path from typing import Any from circuitforge_core.db.base import get_connection from circuitforge_core.db.migrations import run_migrations MIGRATIONS_DIR = Path(__file__).parent / "migrations" class Store: def __init__(self, db_path: Path | str) -> None: self.conn: sqlite3.Connection = get_connection(Path(db_path)) self.conn.row_factory = sqlite3.Row self.conn.execute("PRAGMA journal_mode=WAL") self.conn.execute("PRAGMA foreign_keys=ON") run_migrations(self.conn, MIGRATIONS_DIR) def close(self) -> None: self.conn.close() def _row_to_dict(self, row: sqlite3.Row) -> dict[str, Any]: return dict(row)