dql.models module

Data containers

class dql.models.GlobalIndexMeta(index: dynamo3.fields.GlobalIndex)[source]

Bases: object

Container for global index data

includes[source]

Getter for includes

index_type[source]

Getter for index_type

item_count[source]

Getter for item_count

name[source]

Getter for name

pformat(consumed_capacity=None)[source]

Pretty format for insertion into table pformat

schema[source]

The DQL fragment for constructing this index

size[source]

Getter for size

status[source]

Getter for status

throughput[source]

Getter for throughput

class dql.models.IndexField(name, data_type, index_type, index_name, includes=None)[source]

Bases: dql.models.TableField

A TableField that is also part of a Local Secondary Index

schema[source]

The DQL syntax for creating this item

class dql.models.QueryIndex(name: str, is_global: bool, hash_key: dynamo3.fields.DynamoKey, range_key: Optional[dynamo3.fields.DynamoKey], attributes: Optional[Set[str]] = None)[source]

Bases: object

A representation of global/local indexes that used during query building.

When building queries, we need to detect if the constraints are sufficient to perform a query or if they can only do a scan. This simple container class was specifically create to make that logic simpler.

classmethod from_table_index(table: dynamo3.fields.Table, index: dynamo3.fields.BaseIndex) → dql.models.QueryIndex[source]

Factory method

projects_all_attributes(attrs: Iterable[str]) → bool[source]

Return True if the index projects all the attributes

scannable[source]

Only global indexes can be scanned

class dql.models.TableField(name, data_type, key_type=None)[source]

Bases: object

A DynamoDB table attribute

Parameters:
name : str
data_type : str

The type of object (e.g. ‘STRING’, ‘NUMBER’, etc)

key_type : str, optional

The type of key (e.g. ‘RANGE’, ‘HASH’, ‘INDEX’)

schema[source]

The DQL syntax for creating this item

to_index(index_type, index_name, includes=None)[source]

Create an index field from this field

class dql.models.TableMeta(table: dynamo3.fields.Table, attrs: Dict[str, dql.models.TableField], global_indexes: Dict[str, dql.models.GlobalIndexMeta])[source]

Bases: object

Container for table metadata

Parameters:
table : Table
attrs : dict

Mapping of attribute name to TableField

global_indexes : dict

Mapping of hash key to GlobalIndexMeta

decreases_today[source]

Getter for decreases_today

classmethod from_description(table: dynamo3.fields.Table) → dql.models.TableMeta[source]

Factory method that uses the dynamo3 ‘describe’ return value

get_index(index_name: str) → dql.models.QueryIndex[source]

Get a specific index by name

get_indexes() → Dict[str, dql.models.QueryIndex][source]

Get a dict of index names to index

get_matching_indexes(possible_hash: Set[str], possible_range: Set[str]) → List[dql.models.QueryIndex][source]

Get all indexes that could be queried on using a set of keys.

If any indexes match both hash AND range keys, indexes that only match the hash key will be excluded from the result.

Parameters:
possible_hash : set

The names of fields that could be used as the hash key

possible_range : set

The names of fields that could be used as the range key

is_on_demand[source]

Getter for is_on_demand

item_count[source]

Getter for item_count

iter_query_indexes() → Iterator[dql.models.QueryIndex][source]

Iterator that constructs QueryIndex for all global and local indexes, and a special one for the default table hash & range key with the name ‘TABLE’

name[source]

Getter for name

pformat() → str[source]

Pretty string format

primary_key(hkey, rkey=None)[source]

Construct a primary key dictionary

You can either pass in a (hash_key[, range_key]) as the arguments, or you may pass in an Item itself

primary_key_attributes[source]

Get the names of the primary key attributes as a tuple

primary_key_tuple(item: Dict[KT, VT]) → Union[Tuple[str], Tuple[str, str]][source]

Get the primary key tuple from an item

schema[source]

The DQL query that will construct this table’s schema

size[source]

Getter for size

status[source]

Getter for status

throughput[source]

Getter for throughput

total_read_throughput[source]

Combined read throughput of table and global indexes

total_write_throughput[source]

Combined write throughput of table and global indexes

dql.models.format_throughput(available: float, used: Optional[float] = None) → str[source]

Format the read/write throughput for display