Session.data_model_transaction(*, allow_nested=True)
Create a data model transaction to batch multiple data model changes. Start the transaction with awith statement.
The changes will be visible from other clients (e.g. Atoti UI) once the transaction is closed.
Data model transactions offer “read-your-writes” behavior: changes made inside the transaction are visible to the following statements.
Data model transactions cannot be mixed with data loading operations.
-
Parameters:
allow_nested (bool) –
Whether to allow starting this transaction inside an already running one.
When
False, an error will be raised if this transaction is started while another transaction is already running, regardless of that outer transaction’s value of allow_nested. The benefit of passingFalseis that changes made in this transaction are guaranteed, if not rolled back, to be visible to the statements outside the transaction. The drawback is that it prevents splitting transaction steps in small composable functions. When nested transactions are allowed, changes made by inner transactions contribute transparently to the outer transaction and will only be committed when the outer transaction’s context exits. - Return type: AbstractContextManager[None]
Example
See also:
data_transaction().