Spaces:
Sleeping
Sleeping
Download src/utils/db_utils.py from AliAskariFace/backend-todo-app: direct link, hf CLI and curl.
- Browser
- Download file 715 Bytes
-
https://huggingface.co/spaces/AliAskariFace/backend-todo-app/resolve/main/src/utils/db_utils.py
- Command line
-
hf download hf://spaces/AliAskariFace/backend-todo-app/src/utils/db_utils.py
-
curl -L -o db_utils.py https://huggingface.co/spaces/AliAskariFace/backend-todo-app/resolve/main/src/utils/db_utils.py
715 Bytes
| from sqlmodel import SQLModel | |
| import logging | |
| logger = logging.getLogger(__name__) | |
| def create_tables(): | |
| """Create all database tables on startup.""" | |
| try: | |
| # Import sync_engine here to handle potential initialization errors | |
| from .sync_database import sync_engine | |
| logger.info("Creating database tables...") | |
| # Try to create tables, but don't fail if DB is not available | |
| SQLModel.metadata.create_all(bind=sync_engine) | |
| logger.info("Database tables created successfully.") | |
| except Exception as e: | |
| logger.warning(f"Could not create database tables at startup: {str(e)}") | |
| logger.info("Application will continue without database initialization.") |