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

Method execute_command

pymongo/synchronous/client_bulk.py:624–675  ·  view source on GitHub ↗

Execute commands with w=1 WriteConcern.

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

Source from the content-addressed store, hash-verified

622 break
623
624 def execute_command(
625 self,
626 session: Optional[ClientSession],
627 operation: str,
628 ) -> MutableMapping[str, Any]:
629 """Execute commands with w=1 WriteConcern."""
630 full_result: MutableMapping[str, Any] = {
631 "anySuccessful": False,
632 "error": None,
633 "writeErrors": [],
634 "writeConcernErrors": [],
635 "nInserted": 0,
636 "nUpserted": 0,
637 "nMatched": 0,
638 "nModified": 0,
639 "nDeleted": 0,
640 "insertResults": {},
641 "updateResults": {},
642 "deleteResults": {},
643 }
644 op_id = _randint()
645
646 def retryable_bulk(
647 session: Optional[ClientSession],
648 conn: Connection,
649 retryable: bool,
650 ) -> None:
651 if conn.max_wire_version < 25:
652 raise InvalidOperation(
653 "MongoClient.bulk_write requires MongoDB server version 8.0+."
654 )
655 self._execute_command(
656 self.write_concern,
657 session,
658 conn,
659 op_id,
660 retryable,
661 full_result,
662 )
663
664 self.client._retryable_write(
665 self.is_retryable,
666 retryable_bulk,
667 session,
668 operation,
669 bulk=self,
670 operation_id=op_id,
671 )
672
673 if full_result["error"] or full_result["writeErrors"] or full_result["writeConcernErrors"]:
674 _throw_client_bulk_write_exception(full_result, self.verbose_results)
675 return full_result
676
677 def execute_command_unack(
678 self,

Callers 1

executeMethod · 0.95

Calls 3

_randintFunction · 0.90
_retryable_writeMethod · 0.45

Tested by

no test coverage detected