美文网首页
python关联mongodb后,执行数据报pymongo.er

python关联mongodb后,执行数据报pymongo.er

作者: Minerest | 来源:发表于2019-04-26 13:38 被阅读0次
image.png

可见上图,执行mongo的一些操作时报认证失败,是因为认证的方式未指定。解决方法如下

client = pymongo.MongoClient("mongodb://user:password@ip:port/database?authMechanism=SCRAM-SHA-1")
db = client.get_database("LOAA")
col = db.get_collection("pancake")
print col.find()
for i in col.find():
    print I

参考https://www.jianshu.com/p/d9918b0a3ebc

相关文章

网友评论

      本文标题:python关联mongodb后,执行数据报pymongo.er

      本文链接:https://www.haomeiwen.com/subject/eimfnqtx.html