MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / execute

Method execute

pymongo/asynchronous/client_bulk.py:738–765  ·  view source on GitHub ↗

Execute operations.

(
        self,
        session: Optional[AsyncClientSession],
        operation: str,
    )

Source from the content-addressed store, hash-verified

736 return await self.execute_command_unack(conn)
737
738 async def execute(
739 self,
740 session: Optional[AsyncClientSession],
741 operation: str,
742 ) -> Any:
743 """Execute operations."""
744 if not self.ops:
745 raise InvalidOperation("No operations to execute")
746 if self.executed:
747 raise InvalidOperation("Bulk operations can only be executed once.")
748 self.executed = True
749 session = _validate_session_write_concern(session, self.write_concern)
750
751 if not self.write_concern.acknowledged:
752 async with await self.client._conn_for_writes(session, operation) as connection:
753 if connection.max_wire_version < 25:
754 raise InvalidOperation(
755 "MongoClient.bulk_write requires MongoDB server version 8.0+."
756 )
757 await self.execute_no_results(connection)
758 return ClientBulkWriteResult(None, False, False) # type: ignore[arg-type]
759
760 result = await self.execute_command(session, operation)
761 return ClientBulkWriteResult(
762 result,
763 self.write_concern.acknowledged,
764 self.verbose_results,
765 )

Callers

nothing calls this directly

Calls 6

execute_no_resultsMethod · 0.95
execute_commandMethod · 0.95
InvalidOperationClass · 0.90
_conn_for_writesMethod · 0.45

Tested by

no test coverage detected