-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #329 from techstartucalgary/328-deploy-server
remove mongodb interaction since the cluster is non-existent now
- Loading branch information
Showing
2 changed files
with
37 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,35 @@ | ||
"""Handler for the database""" | ||
import json | ||
# """Handler for the database""" | ||
# import json | ||
|
||
from dotenv.main import load_dotenv | ||
from pymongo import MongoClient | ||
# from dotenv.main import load_dotenv | ||
# from pymongo import MongoClient | ||
|
||
# Getting the connection string | ||
load_dotenv() | ||
# # Getting the connection string | ||
# load_dotenv() | ||
# pylint ignore next line naming and line length | ||
# pylint: disable=C0103, C0301 | ||
connection_string = "mongodb+srv://lifelineteamdb:mypassword1@cluster0.ib2qbgg.mongodb.net/?retryWrites=true&w=majority" | ||
|
||
# Defining a MongoDB client instance | ||
client = MongoClient(connection_string) | ||
# # Defining a MongoDB client instance | ||
# client = MongoClient(connection_string) | ||
|
||
# DB name | ||
db = client["database1"] | ||
# # DB name | ||
# db = client["database1"] | ||
|
||
# Referencing the collection | ||
courses = db["courses"] | ||
# # Referencing the collection | ||
# courses = db["courses"] | ||
|
||
|
||
def insert_course_into_db(sha: str, course_str: str): | ||
"""Inserts a course into the database""" | ||
course = {"sha": sha, "course_str": course_str} | ||
result = courses.insert_one(course) | ||
print("Course inserted with ID:", result.inserted_id) | ||
# def insert_course_into_db(sha: str, course_str: str): | ||
# """Inserts a course into the database""" | ||
# course = {"sha": sha, "course_str": course_str} | ||
# result = courses.insert_one(course) | ||
# print("Course inserted with ID:", result.inserted_id) | ||
|
||
|
||
def query_course_from_db(sha: str): | ||
"""Queries the database for a course with the given sha""" | ||
course = courses.find_one({"sha": sha}) | ||
if course: | ||
print("Found a cached course with ID:", course["_id"]) | ||
return json.loads(course["course_str"]) | ||
print("Didn't find a cached course") | ||
return None | ||
# def query_course_from_db(sha: str): | ||
# """Queries the database for a course with the given sha""" | ||
# course = courses.find_one({"sha": sha}) | ||
# if course: | ||
# print("Found a cached course with ID:", course["_id"]) | ||
# return json.loads(course["course_str"]) | ||
# print("Didn't find a cached course") | ||
# return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters