SyncTransactionalSession¶
- class aerospike_sdk.sync.transactional_session.SyncTransactionalSession[source]¶
Bases:
SyncSessionSync context manager grouping operations into a multi-record transaction.
Every session API (
query,upsert,insert,batch, …) works unchanged insidewith; the activeTxnis threaded onto every policy the builders hand to the PAC.On clean exit the transaction commits; if an exception propagates out the transaction aborts. Explicit
commit(),abort(), androllback()(alias forabort) are available for manual control.Example
>>> with client.create_session().begin_transaction() as tx: ... tx.upsert(accounts.id("A")).bin("balance").set_to(100).execute() ... tx.upsert(accounts.id("B")).bin("balance").set_to(200).execute()
See also
SyncSession.begin_transaction():Preferred construction entry.
- __init__(client, behavior)[source]¶
Construct via
SyncSession.begin_transaction()rather than directly.
- property txn: Txn¶
Return the active
Txn.- Raises:
RuntimeError – If the session has not been entered (no active txn).
- commit()[source]¶
Commit the transaction and return the server-reported status.
- Return type:
CommitStatus