MCPcopy
hub / github.com/psycopg/psycopg / _tpc_prepare_gen

Method _tpc_prepare_gen

psycopg/psycopg/_connection_base.py:650–663  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

648 yield from self._exec_command(self._get_tx_start_command())
649
650 def _tpc_prepare_gen(self) -> PQGen[None]:
651 if not self._tpc:
652 raise e.ProgrammingError(
653 "'tpc_prepare()' must be called inside a two-phase transaction"
654 )
655 if self._tpc[1]:
656 raise e.ProgrammingError(
657 "'tpc_prepare()' cannot be used during a prepared two-phase transaction"
658 )
659 xid = self._tpc[0]
660 self._tpc = (xid, True)
661 yield from self._exec_command(SQL("PREPARE TRANSACTION {}").format(str(xid)))
662 if self._pipeline:
663 yield from self._pipeline._sync_gen()
664
665 def _tpc_finish_gen(
666 self, action: LiteralString, xid: Xid | str | None

Callers 2

tpc_prepareMethod · 0.80
tpc_prepareMethod · 0.80

Calls 4

_exec_commandMethod · 0.95
SQLClass · 0.85
formatMethod · 0.80
_sync_genMethod · 0.80

Tested by

no test coverage detected