dql.models module¶
Data containers
-
class
dql.models.
GlobalIndexMeta
(index: dynamo3.fields.GlobalIndex)[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: 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
-
classmethod
-
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’)
-
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
-
classmethod
from_description
(table: dynamo3.fields.Table) → dql.models.TableMeta[source]¶ Factory method that uses the dynamo3 ‘describe’ return value
-
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
-
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’
-
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
- table :