Replaced env variable DATABASE_PATH with DATA_PATH and DATABASE_FILENAME

This commit is contained in:
2025-05-05 16:56:03 -05:00
parent 2be8865537
commit f062f72017
5 changed files with 61 additions and 21 deletions

View File

@@ -1,9 +1,15 @@
import aiosqlite
from dotenv import load_dotenv
from config import DATABASE_PATH
from pathlib import Path
from config import DATABASE_FILENAME, DATA_PATH
async def get_db():
async with aiosqlite.connect(DATABASE_PATH) as 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("""