PooledQldbSession Reference

class pyqldb.session.pooled_qldb_session.PooledQldbSession(qldb_session, return_session_to_pool)[source]

Represents a pooled session object. See pyqldb.session.qldb_session for more details.

close()[source]

Close this PooledQldbSession and return the underlying QldbSession to the pool.

execute_lambda(query_lambda, retry_indicator=<function PooledQldbSession.<lambda>>)[source]

Calls pyqldb.session.qldb_session.QldbSession.execute_lambda() to implicitly start a transaction, execute the lambda function, and commit the transaction, retrying up to the retry limit if an OCC conflict or retriable exception occurs.

If an InvalidSessionException is received, it is considered a retriable exception by starting a new pyqldb.communication.session_client.SessionClient to use to communicate with QLDB. Thus, as a side effect, this QldbSession can become valid again despite a previous InvalidSessionException from other method calls on this instance, any child transactions, or cursors, when this method is invoked.

Parameters
  • query_lambda (function) – The lambda function to execute. A lambda function cannot have any side effects as it may be invoked multiple times, and the result cannot be trusted until the transaction is committed.

  • retry_indicator (function) – Optional function called when the transaction execution is about to be retried due to an OCC conflict or retriable exception.

Return type

pyqldb.cursor.buffered_cursor.BufferedCursor/object

Returns

The return value of the lambda function which could be a pyqldb.cursor.buffered_cursor.BufferedCursor on the result set of a statement within the lambda.

Raises
  • IllegalStateError – When the commit digest from commit transaction result does not match.

  • SessionClosedError – When this session is closed.

  • ClientError – When there is an error communicating with QLDB.

execute_statement(statement, parameters=[], retry_indicator=<function PooledQldbSession.<lambda>>)[source]

Calls pyqldb.session.qldb_session.QldbSession.execute_statement() to implicitly start a transaction, execute the statement, and commit the transaction, retrying up to the retry limit if an OCC conflict or retriable exception occurs.

If an InvalidSessionException is received, it is considered a retriable exception by starting a new pyqldb.communication.session_client.SessionClient to use to communicate with QLDB. Thus, as a side effect, this QldbSession can become valid again despite a previous InvalidSessionException from other method calls on this instance, any child transactions, or cursors, when this method is invoked.

Parameters
  • statement (str) – The statement to execute.

  • parameters (list) – Optional list of Ion values to fill in parameters of the statement.

  • retry_indicator (function) – Optional function called when the transaction execution is about to be retried due to an OCC conflict or retriable exception.

Return type

pyqldb.cursor.buffered_cursor.BufferedCursor

Returns

Fully buffered Cursor on the result set of the statement.

Raises
  • IllegalStateError – When the commit digest calculated by the client does not match the digest as calculated by the QLDB service.

  • SessionClosedError – When this session is closed.

  • ClientError – When there is an error communicating with QLDB.

property ledger_name

The read-only ledger name.

list_tables()[source]

Get the list of table names in the ledger.

Return type

pyqldb.cursor.buffered_cursor.BufferedCursor

Returns

Iterable of table names in amazon.ion.simple_types.IonPyText format found in the ledger.

Raises

SessionClosedError – When this session is closed.

property session_token

The read-only session token.

start_transaction()[source]

Start a transaction using an available database session.

Return type

pyqldb.transaction.transaction.Transaction

Returns

A new transaction.

Raises

SessionClosedError – When this session is closed.