File size: 1,013 Bytes
f86ba47 c3c927e f86ba47 c3c927e d28c029 f86ba47 d28c029 f86ba47 d28c029 f86ba47 d28c029 f86ba47 d28c029 |
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 35 36 37 38 39 40 41 42 43 |
import os
import certifi
from dotenv import load_dotenv
from pymongo import MongoClient
load_dotenv()
ca = certifi.where()
print("ca:", ca)
client = MongoClient(os.getenv("MONGO_CONNECTION_STRING"), tlsCAFile=ca)
print("Connected to MongoDB")
db = client[os.getenv("MONGO_DB_NAME")]
env_type = os.getenv("ENV_TYPE")
print("env:", env_type)
if env_type == "dev":
collection_name = os.getenv("DEV_MONGO_COLLECTION")
print("Using dev collection")
else:
collection_name = os.getenv("PROD_MONGO_COLLECTION")
print("Using prod collection")
collection = db[collection_name]
print("Using collection:", collection_name)
def save_results(student_name, class_name, model, book, questions, feedback, rating):
print("Saving results")
collection.insert_one({
"student_name": student_name,
"class": class_name,
"model": model,
"book": book,
"questions": questions,
"feedback": feedback,
"rating": rating
})
print("Saved results")
|