command_cursor – Tools for iterating over MongoDB command results¶
CommandCursor class to iterate over command results.
-
class
pymongo.command_cursor.CommandCursor(collection, cursor_info, conn_id, compile_re=True, retrieved=0)¶ Create a new command cursor.
-
alive¶ Does this cursor have the potential to return more data?
-
batch_size(batch_size)¶ Limits the number of documents returned in one batch. Each batch requires a round trip to the server. It can be adjusted to optimize performance and limit data transfer.
Note
batch_size can not override MongoDB’s internal limits on the amount of data it will return to the client in a single batch (i.e if you set batch size to 1,000,000,000, MongoDB will currently only return 4-16MB of results per batch).
Raises
TypeErrorif batch_size is not an integer. RaisesValueErrorif batch_size is less than0.Parameters: - batch_size: The size of each batch of results requested.
-
close()¶ Explicitly close / kill this cursor. Required for PyPy, Jython and other Python implementations that don’t use reference counting garbage collection.
-
cursor_id¶ Returns the id of the cursor.
-
next()¶ Advance the cursor.
-