Spaces:
Runtime error
Runtime error
Download app/database.py from aayushhh-operator/Veda-AI-Backend: direct link, hf CLI and curl.
- Browser
- Download file 456 Bytes
-
https://huggingface.co/spaces/aayushhh-operator/Veda-AI-Backend/resolve/main/app/database.py
- Command line
-
hf download hf://spaces/aayushhh-operator/Veda-AI-Backend/app/database.py
-
curl -L -o database.py https://huggingface.co/spaces/aayushhh-operator/Veda-AI-Backend/resolve/main/app/database.py
456 Bytes
| from motor.motor_asyncio import AsyncIOMotorClient | |
| from app.config import env | |
| client = None | |
| db = None | |
| async def connect_db(): | |
| global client, db | |
| client = AsyncIOMotorClient(env.MONGO_URI) | |
| db = client.get_default_database() | |
| if db.name is None: | |
| db = client["vedaai"] | |
| print("Connected to MongoDB via Motor") | |
| async def close_db(): | |
| global client | |
| if client: | |
| client.close() | |
| print("Disconnected from MongoDB") | |