Skip to content Skip to sidebar Skip to footer

How Do I Retrieve And Print Pymongo.cursor.cursor Objects?

I am creating a simple database CRUD manager using python and connecting it to a MongoDB database. I have connected to my cluster and have retrieved posts before using the exact sa

Solution 1:

just started using mongoDB this morning and came across the same problem. I was looking for a specific value, found it, but got the same result as you. I just put "[0]" at the and got the result. As I said, I just started using mongoDB thats why I don't know why that is.

This got me my result: db.find({"key":"value"})[0]

Solution 2:

I couldn't find a solution so what I tried was to create a new MongoDB project with a new cluster. The original project was using AWS as the cloud provider and region for the cluster. This time I used Azure as the cloud provider and region for the new cluster in the new project.

It is working now and so the problem was lying within the connection to the database. All I did was to set up a new database so actually, the original problem still stands in the old database.

Solution 3:

pymongo.errors.ServerSelectionTimeoutError: connection closed,connection closed,connection closed

Every cluster has 3 replica set nodes. It looks like you couldn't connect to any of them. On your Atlas web interface go to your Security > Network access settings and make sure your IP address is whitelisted there.

Post a Comment for "How Do I Retrieve And Print Pymongo.cursor.cursor Objects?"