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()
Advertisement
Answer
.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.