– Tools for iterating over MongoDB command results
class pymongo.command_cursor.CommandCursor(collection, cursor_info, address, retrieved=0, batch_size=0, max_await_time_ms=None, session=None, explicit_session=False)
Create a new command cursor.
The parameter ‘retrieved’ is unused.
property address
The (host, port) of the server used, or None.
New in version 3.0.
property alive
Does this cursor have the potential to return more data?
Even if alive is , can raise StopIteration. Best to use a for loop:
can be True while iterating a cursor from a failed server. In this case alive will return False after fails to retrieve the next batch of results from the server.
-
Returns the id of the cursor.
next()
Advance the cursor.
class pymongo.command_cursor.RawBatchCommandCursor(collection, cursor_info, address, retrieved=0, batch_size=0, max_await_time_ms=None, session=None, explicit_session=False)
Create a new cursor / iterator over raw batches of BSON data.
Should not be called directly by application developers - see aggregate_raw_batches() instead.
The MongoDB documentation on .