在 Kali Linux 上使用 pymongo 将 JSON 文件上传到 Mongodb
Uploading JSON file to Mongodb with pymongo on Kali Linux
我正在将 Json
文件上传到 MongoDB
,但出现此错误。我正在使用 Linux
.
AttributeError: module 'pymongo' has no attribute 'MongoClient'
但我已经安装了 pymongo
。
def Uploaddb():
client = pymongo.MongoClient("mongodb+srv://username:password@devconnector.g6cxh.mongodb.net/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()
仅使用MongoClient
client = MongoClient("mongodb+srv://<Username>:<password>@devconnector.g6cxh.mongodb.net/myFirstDatabase?retryWrites=true&w=majority", serverSelectionTimeoutMS=10000);
我正在将 Json
文件上传到 MongoDB
,但出现此错误。我正在使用 Linux
.
AttributeError: module 'pymongo' has no attribute 'MongoClient'
但我已经安装了 pymongo
。
def Uploaddb():
client = pymongo.MongoClient("mongodb+srv://username:password@devconnector.g6cxh.mongodb.net/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()
仅使用MongoClient
client = MongoClient("mongodb+srv://<Username>:<password>@devconnector.g6cxh.mongodb.net/myFirstDatabase?retryWrites=true&w=majority", serverSelectionTimeoutMS=10000);