bulk – The bulk write operations interface

    New in version 2.7.

    class pymongo.bulk.BulkOperationBuilder(collection, ordered=True, bypass_document_validation=False)

    DEPRECATED: Initialize a new BulkOperationBuilder instance.

    Note

    bypass_document_validation requires server version >= 3.2

    Changed in version 3.5: Deprecated. Use bulk_write() instead.

    Changed in version 3.2: Added bypass_document_validation support

    • execute(write_concern=None)

      Execute all provided operations.

      Parameters:
      • write_concern (optional): the write concern for this bulk execution.
    • find(selector, collation=None)

      Specify selection criteria for bulk operations.

      Parameters:
      • selector (dict): the selection criteria for update and remove operations.
      • collation (optional): An instance of . This option is only supported on MongoDB 3.4 and above.
      Returns:

        Changed in version 3.4: Added the collation option.

      • Insert a single document.

        See also

        Why does PyMongo add an _id field to all of my documents?

      class pymongo.bulk.BulkUpsertOperation(selector, bulk, collation)

      An interface for adding upsert operations.

      • replace_one(replacement)

        Replace one entire document matching the selector criteria.

        Parameters:
        • replacement (dict): the replacement document
      • update(update)

        Update all documents matching the selector.

        Parameters:
        • update (dict): the update operations to apply
      • (update)

        Update one document matching the selector.

      class pymongo.bulk.BulkWriteOperation(selector, bulk, collation)

      • remove_one()

        Remove a single document matching the selector criteria.

      • replace_one(replacement)

        Replace one entire document matching the selector criteria.

        Parameters:
        • replacement (dict): the replacement document
      • update(update)

        Update all documents matching the selector criteria.

        Parameters:
        • update (dict): the update operations to apply
      • update_one(update)

        Update one document matching the selector criteria.

      • ()

        Specify that all chained update operations should be upserts.

        Returns: