Transactions¶
Transaction wrappers for ACID operations across DynamoDB tables.
transactions ¶
Transaction support for Dynantic.
Provides ACID transactions across DynamoDB tables using TransactWriteItems and TransactGetItems.
TransactPut ¶
Wraps a model instance for transactional put.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
DynamoModel
|
The DynamoModel instance to save. |
required |
condition
|
Condition | None
|
Optional condition expression that must be satisfied for the put to succeed. |
None
|
Example
TransactPut(user, condition=Attr("user_id").not_exists())
Source code in dynantic/transactions.py
TransactDelete ¶
Wraps a delete operation for transactional delete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_cls
|
type[DynamoModel]
|
The DynamoModel class of the item to delete. |
required |
condition
|
Condition | None
|
Optional condition expression that must be satisfied for the delete to succeed. |
None
|
**key_values
|
Any
|
Primary key values identifying the item to delete. |
{}
|
Example
TransactDelete(Order, condition=Attr("status") == "cancelled", order_id="o1")
Source code in dynantic/transactions.py
TransactConditionCheck ¶
Wraps a condition check for transactional validation without modifying the item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_cls
|
type[DynamoModel]
|
The DynamoModel class of the item to check. |
required |
condition
|
Condition
|
Condition expression that must be satisfied for the transaction to succeed. |
required |
**key_values
|
Any
|
Primary key values identifying the item to check. |
{}
|
Example
TransactConditionCheck(Account, Attr("balance") >= 100, account_id="acc-1")
Source code in dynantic/transactions.py
TransactGet ¶
Wraps a get operation for transactional reads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_cls
|
type[DynamoModel]
|
The DynamoModel class of the item to read. |
required |
**key_values
|
Any
|
Primary key values identifying the item to read. |
{}
|
Example
TransactGet(User, user_id="u1")