Spaces:
Runtime error
Runtime error
Update database.py
Browse files- database.py +17 -6
database.py
CHANGED
|
@@ -1,16 +1,27 @@
|
|
| 1 |
from pymongo import MongoClient
|
| 2 |
import os
|
| 3 |
|
| 4 |
-
CER_KEY = os.environ['cer']
|
| 5 |
|
| 6 |
-
uri = "mongodb+srv://cluster0.tzvxqk3.mongodb.net/?authSource=%24external&authMechanism=MONGODB-X509&retryWrites=true&w=majority"
|
| 7 |
-
client = MongoClient(uri,
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
db = client['testDB']
|
| 12 |
collection = db['testCol']
|
| 13 |
-
|
| 14 |
|
| 15 |
def save_response(response_data):
|
| 16 |
"""Saves a response to the MongoDB collection."""
|
|
|
|
| 1 |
from pymongo import MongoClient
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
# CER_KEY = os.environ['cer']
|
| 5 |
|
| 6 |
+
# uri = "mongodb+srv://cluster0.tzvxqk3.mongodb.net/?authSource=%24external&authMechanism=MONGODB-X509&retryWrites=true&w=majority"
|
| 7 |
+
# client = MongoClient(uri,
|
| 8 |
+
# tls=True,
|
| 9 |
+
# tlsCertificateKeyFile=CER_KEY)
|
| 10 |
|
| 11 |
+
# db = client['testDB']
|
| 12 |
+
# collection = db['testCol']
|
| 13 |
+
|
| 14 |
+
###
|
| 15 |
+
|
| 16 |
+
from pymongo.mongo_client import MongoClient
|
| 17 |
+
|
| 18 |
+
uri = f"mongodb+srv://deema2:{os.environ['pw']}@cluster0.tzvxqk3.mongodb.net/?retryWrites=true&w=majority"
|
| 19 |
+
|
| 20 |
+
# Create a new client and connect to the server
|
| 21 |
+
client = MongoClient(uri)
|
| 22 |
db = client['testDB']
|
| 23 |
collection = db['testCol']
|
| 24 |
+
###
|
| 25 |
|
| 26 |
def save_response(response_data):
|
| 27 |
"""Saves a response to the MongoDB collection."""
|