I am a Python developer, and I wanted to point something out, in case it’s confusing later!

PyMongo is super-lazy, so it doesn’t connect to the server when you think it does.

# Create a MongoClient object - DOES NOT CONNECT TO SERVER
client = MongoClient(uri)
    
# Get a database object - DOES NOT CONNECT TO SERVER
db = client[database_name]

# DOES CONNECT TO THE SERVER (because it actually needs to get the list of collection names in the database)
collections = db.list_collection_names()

In this case, if you left out the call to list_collection_names then your uri could be wrong, and you’d never know because PyMongo isn’t even going to attempt to connect to your server. Hope this helps!

Mark