qldb_orm.static package

Submodules

qldb_orm.static.clauses module

qldb_orm.static.clauses.set_statement(*columns)

Generates a PartiQL SET col = ? clause for an arbitrary number of columns.

Parameters

columns (list) – List of columns to include in the SET clause.

Returns

SET clause

Return type

str

qldb_orm.static.clauses.where_equals(*columns)

Generates a PartiQL WHERE column = ? clause for an arbitrary number of columns.

Parameters

columns (list) – List of columns to include in the WHERE clause.

Returns

WHERE clause

Return type

str

qldb_orm.static.clauses.where_in(**columns)

Generates a PartiQL WHERE column IN (?, ? .. , ?) clause for an arbitrary number of columns.

Parameters

columns (dict) – Dictionary with keys of columns to include in the WHERE clause with values of arrays to parameterize the IN.

Returns

WHERE clause

Return type

str

qldb_orm.static.driver module

class qldb_orm.static.driver.Driver

Bases: object

static create_index(driver, table, index)

Static method for generating an index on table

Parameters
  • driver (pyqldb.driver.qldb_driver.QldbDriver) – QLDB Driver

  • table (str) – table to be updated

  • index (str) – index to search against

Returns

iterable containing result

static create_table(driver, table)

Static method for creating a table within a ledger

Parameters
  • driver (pyqldb.driver.qldb_driver.QldbDriver) – QLDB Driver

  • table (str) – table to be updated

Returns

iterable containing result

static down_convert(ion_obj)

Down nonvert an amazon.ion ION object

Parameters

ion_obj ([type]) – an Amazon.ion object.

Returns

JSON object

Return type

dict

static driver(ledger)

Static method for retrieving a QLDB driver

Parameters

ledger (str) – Name of the ledger

Returns

QLDB Driver

Return type

pyqldb.driver.qldb_driver.QldbDriver

static execute(transaction_executor, statement, *params, unsafe=False)

Static method for executing transactions with QLDB driver.

Parameters
  • transaction_executor – Executor is injected into callback function through pyqldb.driver.qldb_driver.execute_lambda method.

  • statement (str) – Parameterized PartialQL query.

  • *params – Arguments for parameterized query.

static history(driver, table, id)

Query table revision history for a particular document metadata ID.

Parameters
  • driver (pyqldb.driver.qldb_driver.QldbDriver) – QLDB Driver

  • table (str) – table to be updated

  • id (str) – metadata id of the document revision history

Returns

iterable containing result

Note

id is not the index of the document. It is the metadata.id associated with the document across revisions. Query entire history to find a particular metadata.id

static history_full(driver, table)

Query entire table revision history.

Parameters
  • driver (pyqldb.driver.qldb_driver.QldbDriver) – QLDB Driver

  • table (str) – table to be updated

Returns

iterable containing result

static insert(driver, document, table)

Static method for inserting document into table

Parameters
  • driver (pyqldb.driver.qldb_driver.QldbDriver) – QLDB Driver

  • document (dict) – document containing fields to insert

  • table (str) – table into which document is inserted

Returns

iterable containing result

static query(driver, query, unsafe=False)

Execute a query against a QLDB ledger table.

Parameters
  • driver (pyqldb.driver.qldb_driver.QldbDriver) – [description]

  • query (str) – PartiQL query

  • unsafe (bool, optional) – Flag on whether to sanitize input, defaults to False

Returns

Iterable containg result

static query_all(driver, table)

Static method for querying table by field.

Parameters
  • driver (pyqldb.driver.qldb_driver.QldbDriver) – QLDB Driver

  • field (str) – field to be searched

  • value (str) – search value

  • table (str) – table to be quiered

Returns

iterable containing result

static query_by_fields(driver, table, **fields)

Static method for querying table by field.

Parameters
  • driver (pyqldb.driver.qldb_driver.QldbDriver) – QLDB Driver

  • fields (dict) – Keyword arguments. A dictionary containing the fields used to construct WHERE clause in query.

Returns

iterable containing result

static query_in_fields(driver, table, **fields)

Static method for querying table where fields match a value in a collection

Parameters
  • driver ([type]) – [description]

  • table ([type]) – [description]

..note::

`python Driver().query_in_fields(driver, table, **{ 'a': ['b', 'c' , 'd'], '1': [ 2, 3, 4] }) ` will search all documents where a field a has a value belonging to the set (‘b’, ‘c’, ‘d’) and a field 1 whose value belongs to the set (2, 3, 4).

static sanitize(obj)

Remove escape characters from data type

Parameters

query (str) – Statement that needs sanitized

Returns

Sanitized query

static tables(ledger)

Return a list of tables in the current QLDB ledger.

Parameters

ledger (str) – Name of the ledger

Returns

List of tables in ledger

Return type

list

static update(driver, document, table, index)

Static method for updating QLDB table

Parameters
  • driver (pyqldb.driver.qldb_driver.QldbDriver) – QLDB Driver

  • document (dict) – document to be updated

  • table (dict) – name of the table where the document is

  • index (str) – name of the table index

Returns

iterable containing result set

qldb_orm.static.logger module

qldb_orm.static.logger.getLogger(name: str) logging.Logger

Returns an instance of the logging.Logger class configured to print events on the logging.INFO level to stdout. Add special methods for logging application environment and logging dictionaries, via the log_env and log_dict methods.

Parameters

name (str) – Name of the module instantiating the logging.Logger.

Returns

Instance of Logger.

Return type

logging.Logger

qldb_orm.static.objects module

class qldb_orm.static.objects.Strut(**kwargs)

Bases: object

Simple object to parse qldb_orm.qldb.Document. Used to deserialize QLDB responses into Python native objects, with attributes accessible through object properties, i.e., the document ```json {

‘a’: {
‘b’{

‘c’ : ‘d’

}

}

gets parsed into an object, such that `python object.a.b.c == 'd' `

to_json()
class qldb_orm.static.objects.StrutEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Bases: json.encoder.JSONEncoder

Encoder object to deserialize qldb_orm.static.objects.Strut into string.

default(obj)

Method to convert qldb_orm.static.objects.Strut into deserializable object. Overrides json.default and adds a check for Strut objects.

Module contents