dql.models module¶
Data containers
-
class
dql.models.
GlobalIndex
(name, index_type, status, hash_key, range_key, read_throughput, write_throughput, size, includes=None, description=None)[source]¶ Bases:
object
Container for global index data
-
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
-
class
dql.models.
QueryIndex
(name, is_global, hash_key, range_key, attributes=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.
-
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’)
- index_name : str, optional
If the key_type is ‘INDEX’, this will be the name of the index that uses the field as a range key.
-
class
dql.models.
TableMeta
(table, attrs, global_indexes, read_throughput, write_throughput, decreases_today, size)[source]¶ Bases:
object
Container for table metadata
Parameters: - name : str
- status : str
- attrs : dict
Mapping of attribute name to
TableField
- global_indexes : dict
Mapping of hash key to
GlobalIndex
- read_throughput : int
- write_throughput : int
- decreases_today : int
- size : int
Size of the table in bytes
- item_count : int
Number of items in the table
-
classmethod
from_description
(cls, table)[source]¶ Factory method that uses the dynamo3 ‘describe’ return value
-
get_matching_indexes
(self, possible_hash, possible_range)[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
-
iter_query_indexes
(self)[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’