'How to wait pymongo find() results without looping all rows?
Not getting any result in pymongo by find() function in my collection:
But if I loop that variable, then it loads:
The only thing I did is adding a loop (see line ):
for row in local_data:
print(row)
So if I put that loop it will load all rows and I will see retrieved: 46
How can I wait it to return results without looping like that? Something like mycollection.find().Wait()
Solution 1:[1]
.find() returns an iterable cursor. You have to iterate it (e.g. with a for loop) to get the results. If you don't iterate it, it doesn't do anything.
You can wrap the find in a list() command that will create a list of returned documents.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Belly Buster |


