DynamoDB customization reference#

Valid DynamoDB types#

These are the valid item types to use with Boto3 Table Resource (dynamodb.Table) and DynamoDB:

Python Type

DynamoDB Type

string

String (S)

integer

Number (N)

decimal.Decimal

Number (N)

boto3.dynamodb.types.Binary

Binary (B)

boolean

Boolean (BOOL)

None

Null (NULL)

string set

String Set (SS)

integer set

Number Set (NS)

decimal.Decimal set

Number Set (NS)

boto3.dynamodb.types.Binary set

Binary Set (BS)

list

List (L)

dict

Map (M)

Custom Boto3 types#

class boto3.dynamodb.types.Binary(value)[source]#

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.

DynamoDB conditions#

class boto3.dynamodb.conditions.Key(name)[source]#
begins_with(value)#

Creates a condition where the attribute begins with the value.

Parameters:

value – The value that the attribute begins with.

between(low_value, high_value)#

Creates a condition where the attribute is greater than or equal to the low value and less than or equal to the high value.

Parameters:
  • low_value – The value that the attribute is greater than or equal to.

  • high_value – The value that the attribute is less than or equal to.

eq(value)#

Creates a condition where the attribute is equal to the value.

Parameters:

value – The value that the attribute is equal to.

gt(value)#

Creates a condition where the attribute is greater than the value.

Parameters:

value – The value that the attribute is greater than.

gte(value)#
Creates a condition where the attribute is greater than or equal to

the value.

Parameters:

value – The value that the attribute is greater than or equal to.

lt(value)#

Creates a condition where the attribute is less than the value.

Parameters:

value – The value that the attribute is less than.

lte(value)#
Creates a condition where the attribute is less than or equal to the

value.

Parameters:

value – The value that the attribute is less than or equal to.

class boto3.dynamodb.conditions.Attr(name)[source]#

Represents an DynamoDB item’s attribute.

attribute_type(value)[source]#

Creates a condition for the attribute type.

Parameters:

value – The type of the attribute.

begins_with(value)#

Creates a condition where the attribute begins with the value.

Parameters:

value – The value that the attribute begins with.

between(low_value, high_value)#

Creates a condition where the attribute is greater than or equal to the low value and less than or equal to the high value.

Parameters:
  • low_value – The value that the attribute is greater than or equal to.

  • high_value – The value that the attribute is less than or equal to.

contains(value)[source]#

Creates a condition where the attribute contains the value.

Parameters:

value – The value the attribute contains.

eq(value)#

Creates a condition where the attribute is equal to the value.

Parameters:

value – The value that the attribute is equal to.

exists()[source]#

Creates a condition where the attribute exists.

gt(value)#

Creates a condition where the attribute is greater than the value.

Parameters:

value – The value that the attribute is greater than.

gte(value)#
Creates a condition where the attribute is greater than or equal to

the value.

Parameters:

value – The value that the attribute is greater than or equal to.

is_in(value)[source]#

Creates a condition where the attribute is in the value,

Parameters:

value (list) – The value that the attribute is in.

lt(value)#

Creates a condition where the attribute is less than the value.

Parameters:

value – The value that the attribute is less than.

lte(value)#
Creates a condition where the attribute is less than or equal to the

value.

Parameters:

value – The value that the attribute is less than or equal to.

ne(value)[source]#

Creates a condition where the attribute is not equal to the value

Parameters:

value – The value that the attribute is not equal to.

not_exists()[source]#

Creates a condition where the attribute does not exist.

size()[source]#

Creates a condition for the attribute size.

Note another AttributeBase method must be called on the returned size condition to be a valid DynamoDB condition.