File size: 1,079 Bytes
05cb41b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# from motor.motor_asyncio import AsyncIOMotorClient
# from app.core.config import settings

# class Database:
#     client: AsyncIOMotorClient = None

# db = Database()

# async def connect_to_mongo():
#     """Initialize the MongoDB connection pool."""
#     db.client = AsyncIOMotorClient(settings.MONGO_URI)
#     print("✅ Connected to MongoDB")

# async def close_mongo_connection():
#     """Close the MongoDB connection pool."""
#     if db.client:
#         db.client.close()
#         print("🛑 Closed MongoDB connection")

# def get_database():
#     """Dependency to retrieve the database instance."""
#     return db.client[settings.DB_NAME]

import os
from motor.motor_asyncio import AsyncIOMotorClient

# Defaulting to localhost, but update this with your MongoDB Atlas URI in production
MONGO_URI = os.getenv("MONGO_URI", "mongodb+srv://sudhanp2004:root@cluster0.wsmrt.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0")

client = AsyncIOMotorClient(MONGO_URI)
db = client.medical_adjudication

users_collection = db.users
claims_collection = db.claims