我正在尝试通过 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)
Run Code Online (Sandbox Code Playgroud)
然后我收到以下错误:
[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)
Run Code Online (Sandbox Code Playgroud)
我再次逐行尝试,一切正常,直到我尝试计算我的收藏中的文档数量。我很感激我能得到的所有帮助。