Pymongo allowDiskUse=True and Empty Cursor

Hi All,

I have a question regarding allowDiskUse=True, I am using pymongo and I wrote a large query and due to it
size I have to use allowDiskUse=True in order to make the query run, but when I’m looping through the received cursor object it seems as it empty.
Can someone please show how to loop through received data ?

Thanks

Hi @Andrey_Krimer welcome to the community!

The code you posted for looping through the result set looks ok, so it might be the query itself. For some simple sanity check: is the query actually returns anything (e.g. try it out in the mongo shell), does the collection has any data in it, and please check if you’re connecting to the correct server :slight_smile:

Best regards,
Kevin

Hi Kevin

Thank yo for your answer, yes I have run via Robo 3T as well and yes it is returning large amount of entries.

Hi @Andrey_Krimer

I suggest trying out with a simpler query (e.g. a small find()) and check if it returns the expected result.

Since there is nothing wrong with your looping code, and you are certain you are connected to the correct server and the correct database, the only place to look is the query itself and how the method was called.

If you can post a simplified code, it will be helpful to spot issues with it.

Best regards
Kevin

Hi @kevinadi

You were correct, it was my query, I have resolved it and it work now,
thank you for your answer and support :slight_smile:

Thanks
Andrey