boto3.dynamodb.types

Module Contents

STRING = S
NUMBER = N
BINARY = B
STRING_SET = SS
NUMBER_SET = NS
BINARY_SET = BS
NULL = NULL
BOOLEAN = BOOL
MAP = M
LIST = L
DYNAMODB_CONTEXT
BINARY_TYPES
class Binary(value)

Bases:object

A class for representing Binary in dynamodb

Especially for Python 2, use this class to explicitly specify binary data for item in DynamoDB. It is essentially a wrapper around binary. Unicode and Python 3 string types are not allowed.

__eq__(self, other)
__ne__(self, other)
__repr__(self)
__str__(self)
__hash__(self)
class TypeSerializer

Bases:object

This class serializes Python data types to DynamoDB types.

serialize(self, value)

The method to serialize the Python data types.

Parameters:value

A python value to be serialized to DynamoDB. Here are the various conversions:

Python DynamoDB —— ——– None {‘NULL’: True} True/False {‘BOOL’: True/False} int/Decimal {‘N’: str(value)} string {‘S’: string} Binary/bytearray/bytes (py3 only) {‘B’: bytes} set([int/Decimal]) {‘NS’: [str(value)]} set([string]) {‘SS’: [string]) set([Binary/bytearray/bytes]) {‘BS’: [bytes]} list {‘L’: list} dict {‘M’: dict}

For types that involve numbers, it is recommended that Decimal objects are used to be able to round-trip the Python type. For types that involve binary, it is recommended that Binary objects are used to be able to round-trip the Python type.

Return type:dict
Returns:A dictionary that represents a dynamoDB data type. These dictionaries can be directly passed to botocore methods.
_get_dynamodb_type(self, value)
_is_null(self, value)
_is_boolean(self, value)
_is_number(self, value)
_is_string(self, value)
_is_binary(self, value)
_is_set(self, value)
_is_type_set(self, value, type_validator)
_is_map(self, value)
_is_list(self, value)
_serialize_null(self, value)
_serialize_bool(self, value)
_serialize_n(self, value)
_serialize_s(self, value)
_serialize_b(self, value)
_serialize_ss(self, value)
_serialize_ns(self, value)
_serialize_bs(self, value)
_serialize_l(self, value)
_serialize_m(self, value)
class TypeDeserializer

Bases:object

This class deserializes DynamoDB types to Python types.

deserialize(self, value)

The method to deserialize the DynamoDB data types.

Parameters:value

A DynamoDB value to be deserialized to a pythonic value. Here are the various conversions:

DynamoDB Python ——– —— {‘NULL’: True} None {‘BOOL’: True/False} True/False {‘N’: str(value)} Decimal(str(value)) {‘S’: string} string {‘B’: bytes} Binary(bytes) {‘NS’: [str(value)]} set([Decimal(str(value))]) {‘SS’: [string]} set([string]) {‘BS’: [bytes]} set([bytes]) {‘L’: list} list {‘M’: dict} dict

Returns:The pythonic value of the DynamoDB type.
_deserialize_null(self, value)
_deserialize_bool(self, value)
_deserialize_n(self, value)
_deserialize_s(self, value)
_deserialize_b(self, value)
_deserialize_ns(self, value)
_deserialize_ss(self, value)
_deserialize_bs(self, value)
_deserialize_l(self, value)
_deserialize_m(self, value)