Update db/mongo.py
Browse files- db/mongo.py +5 -15
db/mongo.py
CHANGED
@@ -1,19 +1,9 @@
|
|
1 |
-
|
2 |
import os
|
3 |
-
from fastapi import HTTPException
|
4 |
-
from bson.objectid import ObjectId
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
if
|
9 |
-
raise HTTPException(status_code=500, detail="MONGODB_URI not set in environment")
|
10 |
|
11 |
-
# Create MongoDB client
|
12 |
-
client = motor.motor_asyncio.AsyncIOMotorClient(MONGODB_URI)
|
13 |
-
|
14 |
-
# Access the database (you can change the DB name here if needed)
|
15 |
-
db = client.get_default_database()
|
16 |
-
|
17 |
-
# Access collections
|
18 |
patients_collection = db["patients"]
|
19 |
-
|
|
|
1 |
+
from motor.motor_asyncio import AsyncIOMotorClient
|
2 |
import os
|
|
|
|
|
3 |
|
4 |
+
MONGODB_URI = os.getenv("MONGODB_URI") # Make sure it's added to your Hugging Face Space secrets
|
5 |
+
client = AsyncIOMotorClient(MONGODB_URI)
|
6 |
+
db = client["cps_db"] # Adjust if your database name is different
|
|
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
patients_collection = db["patients"]
|
9 |
+
results_collection = db["txagent_results"]
|