From 8b30082b61f12f117feb9a044bef1c997a8364e0 Mon Sep 17 00:00:00 2001 From: Brandon Le Date: Tue, 20 Jun 2023 00:06:34 -0400 Subject: [PATCH] Added delete all documents function --- mongoSaver.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mongoSaver.py b/mongoSaver.py index d86af4c..dd4a9df 100644 --- a/mongoSaver.py +++ b/mongoSaver.py @@ -33,5 +33,25 @@ def save_csv_to_mongo(self, collection_name, csv_path): except Exception as e: print(e) + def delete_all(self): + # Access the desired database + database = self.client[DB_NAME] + + # Access the collection + collection = database["crns"] + + # Delete all documents in the collection + collection.delete_many({}) + + # Access the collection + collection = database["courses"] + + # Delete all documents in the collection + collection.delete_many({}) + + print("Deleted all documents in Courses and Crns") + + + def close_mongo_connection(self): self.client.close() \ No newline at end of file