import sqlite3 from pathlib import Path DATABASE_PATH = Path(__file__).parent.parent / "data" / "reviews.db" def get_db(): """ FastAPI dependency that provides a database connection. Yields a connection, then closes it when the request is done. """ conn = sqlite3.connect(DATABASE_PATH) conn.row_factory = sqlite3.Row try: yield conn finally: conn.close()