Spaces:
Sleeping
Sleeping
File size: 389 Bytes
14c4d51 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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()
|