Spaces:
Sleeping
Sleeping
Download src/infrastructure/database.py from exploreshree/jarvis-backend: direct link, hf CLI and curl.
- Browser
- Download file 389 Bytes
-
https://huggingface.co/spaces/exploreshree/jarvis-backend/resolve/main/src/infrastructure/database.py
- Command line
-
hf download hf://spaces/exploreshree/jarvis-backend/src/infrastructure/database.py
-
curl -L -o database.py https://huggingface.co/spaces/exploreshree/jarvis-backend/resolve/main/src/infrastructure/database.py
389 Bytes
| from motor.motor_asyncio import AsyncIOMotorClient | |
| from src.core.config import settings | |
| class Database: | |
| client: AsyncIOMotorClient = None | |
| db = None | |
| db = Database() | |
| async def connect_to_mongo(): | |
| db.client = AsyncIOMotorClient(settings.MONGODB_URL) | |
| db.db = db.client[settings.DATABASE_NAME] | |
| async def close_mongo_connection(): | |
| if db.client: | |
| db.client.close() | |