github-actions[bot]
Automated deployment from GitHub Actions: a9d5a91de63ad7224bafe6039fb2b7479388fbf4
0a8c81b Download src/models/database.py from VLTA-AI/dropshop: direct link, hf CLI and curl.
- Browser
- Download file 713 Bytes
-
https://huggingface.co/spaces/VLTA-AI/dropshop/resolve/main/src/models/database.py
- Command line
-
hf download hf://spaces/VLTA-AI/dropshop/src/models/database.py
-
curl -L -o database.py https://huggingface.co/spaces/VLTA-AI/dropshop/resolve/main/src/models/database.py
713 Bytes
| from sqlmodel import SQLModel, create_engine, Session | |
| from sqlalchemy.dialects import registry | |
| from src.core.config import settings | |
| # Register the libsql dialect manually to bypass uvicorn/uv entry_points cache issues on Hugging Face | |
| registry.register("sqlite.libsql", "sqlalchemy_libsql.libsql", "SQLiteDialect_libsql") | |
| from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor | |
| engine = create_engine( | |
| settings.get_sqlalchemy_url, | |
| echo=True, | |
| connect_args=settings.get_sqlalchemy_connect_args | |
| ) | |
| # Instrument the database engine for tracing | |
| SQLAlchemyInstrumentor().instrument( | |
| engine=engine, | |
| ) | |
| def get_session(): | |
| with Session(engine) as session: | |
| yield session | |