I am uploading the Json
file to MongoDB
but I am getting this error. I am using Linux
.
AttributeError: module 'pymongo' has no attribute 'MongoClient'
but I have already installed pymongo
.
def Uploaddb():
client = pymongo.MongoClient("mongodb srv://username:[email protected]/myFirstDatabase?retryWrites=true&w=majority")
db = client['Linux_Trace_db']
linux_trace = db['linux_trace']
with open('trace.json') as f:
data = json.load(f)
linux_trace.insert_many(data)
client.close()
Uploaddb()
CodePudding user response:
Use only MongoClient
client = MongoClient("mongodb srv://<Username>:<password>@devconnector.g6cxh.mongodb.net/myFirstDatabase?retryWrites=true&w=majority", serverSelectionTimeoutMS=10000);