MCPcopy
hub / github.com/tortoise/tortoise-orm / in_transaction

Function in_transaction

tortoise/transactions.py:33–44  ·  view source on GitHub ↗

Transaction context manager. You can run your code inside ``async with in_transaction():`` statement to run it into one transaction. If error occurs transaction will rollback. :param connection_name: name of connection to run with, optional if you have only

(connection_name: str | None = None)

Source from the content-addressed store, hash-verified

31
32
33def in_transaction(connection_name: str | None = None) -> TransactionContext:
34 """
35 Transaction context manager.
36
37 You can run your code inside ``async with in_transaction():`` statement to run it
38 into one transaction. If error occurs transaction will rollback.
39
40 :param connection_name: name of connection to run with, optional if you have only
41 one db connection
42 """
43 connection = _get_connection(connection_name)
44 return connection._in_transaction()
45
46
47def atomic(connection_name: str | None = None) -> Callable[[F], F]:

Calls 2

_get_connectionFunction · 0.85
_in_transactionMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…