pyqldb.transaction.transaction.
Transaction
(session, read_ahead, transaction_id, executor)[source]¶A class representing a QLDB transaction.
Every transaction is tied to a parent (Pooled)QldbSession, meaning that if the parent session is closed or
invalidated, the child transaction is automatically closed and cannot be used. Only one transaction can be active at
any given time per parent session, and thus every transaction should call
pyqldb.transaction.transaction.Transaction.abort()
or
pyqldb.transaction.transaction.Transaction.commit()
when it is no longer needed, or when a new transaction
is desired from the parent session.
An InvalidSessionException indicates that the parent session is dead, and a new transaction cannot be created without a new (Pooled)QldbSession being created from the parent driver.
Any unexpected errors that occur within a transaction should not be retried using the same transaction, as the state of the transaction is now ambiguous.
When an OCC conflict occurs, the transaction is closed and must be handled manually by creating a new transaction and re-executing the desired queries.
Child Cursor objects will be closed when the transaction is aborted or committed.
session (pyqldb.communication.session_client.SessionClient
) – The session object representing a communication channel with QLDB.
read_ahead (int) – The number of read-ahead buffers used in retrieving results.
transaction_id (str) – The ID of a transaction.
executor (concurrent.futures.thread.ThreadPoolExecutor
) – The executor to be used by the retrieval thread.
abort
()[source]¶Abort this transaction and close child cursors. No-op if already closed by commit or previous abort.
commit
()[source]¶Commit this transaction and close child cursors.
IllegalStateError – When the commit digest from commit transaction result does not match.
TransactionClosedError – When this transaction is closed.
ClientError – When there is an error communicating with QLDB.
execute_statement
(statement, parameters=[])[source]¶Execute the statement.
statement (str/function) – The statement to execute.
parameters (list) – Optional list of Ion values to fill in parameters of the statement.
pyqldb.cursor.stream_cursor
/object
Cursor on the result set of the statement.
TransactionClosedError – When this transaction is closed.
ClientError – When there is an error communicating with QLDB.
is_closed
¶The read-only flag indicating if this transaction has been committed or aborted.
transaction_id
¶The read-only ID of this transaction.