Точный код, который я использую, приведен ниже:
Код: Выделить всё
from pymongo.mongo_client import MongoClient
# I replaced
with my own password
uri = "mongodb+srv://admin:@cluster0.hkzvmvh.mongodb.net/?retryWrites=true&w=majority"
# Create a new client and connect to the server
client = MongoClient(uri)
# Send a ping to confirm a successful connection
try:
client.admin.command('ping')
print("Pinged your deployment. You successfully connected to MongoDB!")
except Exception as e:
print(e)
Подробнее здесь: https://stackoverflow.com/questions/767 ... hon-client