import aiosqlite from pathlib import Path from src.config import DATABASE_FILENAME, DATA_PATH async def get_db(): # Build the full database path db_path = Path(DATA_PATH) / DATABASE_FILENAME # Ensure the directory exists db_path.parent.mkdir(parents=True, exist_ok=True) async with aiosqlite.connect(db_path) as db: # Enable WAL mode for better concurrency await db.execute("PRAGMA journal_mode=WAL;") await db.execute(""" CREATE TABLE IF NOT EXISTS users ( username TEXT PRIMARY KEY, hashed_password TEXT ) """) await db.commit() yield db