TxAgent-Api / db /mongo.py
Ali2206's picture
Update db/mongo.py
c945f24 verified
raw
history blame contribute delete
573 Bytes
import os
from motor.motor_asyncio import AsyncIOMotorClient
# MongoDB URI (must be set in Hugging Face Secrets)
MONGO_URI = os.environ.get("MONGODB_URI")
if not MONGO_URI:
raise ValueError("MONGODB_URI environment variable is not set.")
# Initialize MongoDB client
client = AsyncIOMotorClient(MONGO_URI)
# Use the correct database name explicitly
db = client["cps_db"]
# Collections
patients_collection = db["patients"]
results_collection = db["patient_analysis_results"]
# Optional utility function to reuse the client
def get_mongo_client():
return client