MCPcopy
hub / github.com/psycopg/psycopg / transaction

Method transaction

psycopg/psycopg/connection.py:345–363  ·  psycopg/psycopg/connection.py::Connection.transaction

Start a context block with a new transaction or nested transaction. :param savepoint_name: Name of the savepoint used to manage a nested transaction. If `!None`, one will be chosen automatically. :param force_rollback: Roll back the transaction at the end of the

(
        self, savepoint_name: str | None = None, force_rollback: bool = False
    )

Source from the content-addressed store, hash-verified

343
344 @contextmanager
345 def transaction(
346 self, savepoint_name: str | None = None, force_rollback: bool = False
347 ) -> Iterator[Transaction]:
348 class="st">"""
349 Start a context block with a new transaction or nested transaction.
350
351 :param savepoint_name: Name of the savepoint used to manage a nested
352 transaction. If `!None`, one will be chosen automatically.
353 :param force_rollback: Roll back the transaction at the end of the
354 block even if there were no error (e.g. to try a no-op process).
355 :rtype: Transaction
356 class="st">"""
357 tx = Transaction(self, savepoint_name, force_rollback)
358 if self._pipeline:
359 with self.pipeline(), tx, self.pipeline():
360 yield tx
361 else:
362 with tx:
363 yield tx
364
365 def notifies(
366 self, *, timeout: float | None = None, stop_after: int | None = None

Calls 2

pipelineMethod · 0.95
TransactionClass · 0.85