I was trying to save data from jupyter notebook in Visual Studio Code into my local mongoDB database. Previously, I had multiple databases in my local mongoDB server. However, after running the pymongo code, all the existing databases got deleted and only the new database that was created in the python code exists. Is there a reason because of which this has occurred? How can I resolve it?
Here's the code I had used for the same:
# Making a Connection with MongoClient
client = MongoClient("mongodb://localhost:27017/")
# database
db = client["stocks_database"]
# collection
company= db["Company"]
db.list_collection_names()
company.insert_one({"index":"Sensex","data":'abc'})