Spaces:
Runtime error
Runtime error
Commit
·
b3494c5
1
Parent(s):
1dec04a
Upload folder using huggingface_hub
Browse files- db_func.py +18 -0
db_func.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import pymongo
|
3 |
+
|
4 |
+
user_name = os.getenv("MONGO_DB_USERNAME")
|
5 |
+
password = os.getenv("MONGO_DB_PASSWORD")
|
6 |
+
|
7 |
+
# Replace these with your MongoDB cluster connection details
|
8 |
+
mongo_uri = uri = f"mongodb+srv://{user_name}:{password}@cluster0.mrrq3sf.mongodb.net/?retryWrites=true&w=majority"
|
9 |
+
database_name = "ophthal-llm"
|
10 |
+
collection_name = "ophthal-llm"
|
11 |
+
|
12 |
+
|
13 |
+
def insert_one(document):
|
14 |
+
client = pymongo.MongoClient(mongo_uri)
|
15 |
+
db = client[database_name]
|
16 |
+
collection = db[collection_name]
|
17 |
+
collection.insert_one(document)
|
18 |
+
client.close()
|