Download app/db/database.py from jebin2/OCR: direct link, hf CLI and curl.
- Browser
- Download file 869 Bytes
-
https://huggingface.co/spaces/jebin2/OCR/resolve/main/app/db/database.py
- Command line
-
hf download hf://spaces/jebin2/OCR/app/db/database.py
-
curl -L -o database.py https://huggingface.co/spaces/jebin2/OCR/resolve/main/app/db/database.py
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.") | |