OCR / app /db /database.py
github-actions[bot]
Auto-deploy from GitHub: 48eb1bb0a56448763c25a67b22cabdf45eae8a7e
826cc86
raw
history blame contribute delete
869 Bytes
import aiosqlite
from app.core.config import settings
from custom_logger import logger_config as logger
async def init_db():
logger.info(f"Initializing database at {settings.DATABASE_FILE}")
async with aiosqlite.connect(settings.DATABASE_FILE) as db:
await db.execute('''CREATE TABLE IF NOT EXISTS image_files
(id TEXT PRIMARY KEY,
filename TEXT NOT NULL,
filepath TEXT NOT NULL,
status TEXT NOT NULL,
result TEXT,
created_at TEXT NOT NULL,
processed_at TEXT,
progress INTEGER DEFAULT 0,
progress_text TEXT,
hide_from_ui INTEGER DEFAULT 0)'''
)
await db.commit()
logger.info("Database initialized successfully.")