我正在尝试通过 atlas 和 pymongo 建立与我的 mongodb 数据库的连接。我正在使用 atlas 页面提供的连接字符串连接我的应用程序,一切似乎都运行良好。我可以连接到我的数据库,但是当我尝试计算我的数据库中有多少条目/检索/将数据发送到 atlas 时,我收到一条错误消息。
import pymongo
import dns
client = pymongo.MongoClient("mongodb+srv://username:<password>@storedinputs-vc4cl.mongodb.net/test?retryWrites=true")
db = client.get_database("dbname")
records = db.collectiontable
count = records.count_documents({})
print(count)
然后我得到以下错误:
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issue
r certificate (_ssl.c:1056),storedinputs-shard-00-00-vc4cl.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] cer
tificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
我再次逐行尝试,一切正常,直到我尝试计算我收藏中的文档数量。我很感激我能得到的所有帮助。
最佳答案
尝试
client = pymongo.MongoClient("mongodb+srv://username:<password>@storedinputs-vc4cl.mongodb.net/test", ssl=True,ssl_cert_reqs='CERT_NONE')
它应该可以工作。
关于python - Pymongo错误通过atlas连接到mongodb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55963264/