Skip to the content.

Expressions

Auto-generated documentation for dynamo_query.expressions module.

Expression builders.

ConditionExpression

[find in source code]

class ConditionExpression(BaseConditionExpression):
    def __init__(
        key: str,
        operator: ConditionExpressionOperatorStr = '=',
        value: Any = None,
    ):

Part of ConditionExpression.

ConditionExpression(key='name', operator=Operator.IN, value='test').render()
# '{key} IN ({test__value})'

Arguments

See also

ConditionExpression().get_format_keys

[find in source code]

def get_format_keys() -> Set[str]:

Get required format keys.

Returns

A set of keys.

ConditionExpression().get_format_values

[find in source code]

def get_format_values() -> Set[str]:

Get required format values without value postfix.

Returns

A set of keys.

ConditionExpression().get_operators

[find in source code]

def get_operators() -> Set[ConditionExpressionOperatorStr]:

Get a set of all operators that used in expession group.

ExpressionError

[find in source code]

class ExpressionError(Exception):

ProjectionExpression

[find in source code]

class ProjectionExpression(BaseExpression):
    def __init__(*keys: str):

Renderer for a format-ready ProjectionExpression.

from dynamo_query.expressions import ProjectionExpression

projection_expression = ProjectionExpression(
    ['first_name', 'last_name']
)
projection_expression.render() # '{first_name}, {last_name}'

Arguments

See also

ProjectionExpression().get_format_keys

[find in source code]

def get_format_keys() -> Set[str]:

Get required format keys.

Returns

A set of keys.

ProjectionExpression().get_format_values

[find in source code]

def get_format_values() -> Set[str]:

Get required format values without value postfix.

Returns

A set of keys.

ProjectionExpression().get_operators

[find in source code]

def get_operators() -> Set[ConditionExpressionOperatorStr]:

Get a set of all operators that used in expession group.

UpdateExpression

[find in source code]

class UpdateExpression(BaseExpression):
    def __init__(
        update: Iterable[str] = tuple(),
        set_if_not_exists: Iterable[str] = tuple(),
        add: Iterable[str] = tuple(),
        delete: Iterable[str] = tuple(),
        remove: Iterable[str] = tuple(),
        *args: str,
    ):

Renderer for format-ready UpdateExpression.

update_expression = UpdateExpression(
    update=['first_name'],
    set_if_not_exists=['created_at'],
    add=['tags'],
)
update_expression
# (
#   'SET {first_name} = {first_name__value},'
#   ' {created_at} = if_not_exists({created_at}, {created_at__value})
#   ' ADD {tags} {tags__value}'
# )

Arguments

See also

UpdateExpression().get_format_keys

[find in source code]

def get_format_keys() -> Set[str]:

Get required format keys.

Returns

A set of keys.

UpdateExpression().get_format_values

[find in source code]

def get_format_values() -> Set[str]:

Get required format values without value postfix.

Returns

A set of keys.

UpdateExpression().get_operators

[find in source code]

def get_operators() -> Set[ConditionExpressionOperatorStr]:

Get a set of all operators that used in expession group.

UpdateExpression().validate_input_data

[find in source code]

def validate_input_data(data: Dict[(str, Any)]) -> None:

Validate data that is used to format the expression. ADD and DELETE directives allow only sets and numbers.

Arguments

Raises