Skip to content

DynamoDBServiceResource#

Index > DynamoDB > DynamoDBServiceResource

Auto-generated documentation for DynamoDB type annotations stubs module mypy-boto3-dynamodb.

DynamoDBServiceResource#

Type annotations and code completion for boto3.resource("dynamodb"), included resources and collections. boto3 documentation

# DynamoDBServiceResource usage example

from mypy_boto3_dynamodb.service_resource import DynamoDBServiceResource

def get_dynamodb_resource() -> DynamoDBServiceResource:
    return boto3.resource("dynamodb")

Attributes#

Collections#

ServiceResourceTablesCollection#

Provides access to Table resource.

Type annotations and code completion for boto3.resource("dynamodb").tables collection. boto3 documentation

# ServiceResourceTablesCollection usage example

from mypy_boto3_dynamodb.service_resource import ServiceResourceTablesCollection

def get_collection() -> ServiceResourceTablesCollection:
    return boto3.resource("dynamodb").tables

Methods#

DynamoDBServiceResource.Table method#

Creates a Table resource.

Type annotations and code completion for boto3.resource("dynamodb").Table method. boto3 documentation

# Table method definition

def Table(
    self,
    name: str,
) -> Table:
    ...

DynamoDBServiceResource.batch_get_item method#

The BatchGetItem operation returns the attributes of one or more items from one or more tables.

Type annotations and code completion for boto3.resource("dynamodb").batch_get_item method. boto3 documentation

# batch_get_item method definition

def batch_get_item(
    self,
    *,
    RequestItems: Mapping[str, KeysAndAttributesServiceResourceTypeDef],  # (1)
    ReturnConsumedCapacity: ReturnConsumedCapacityType = ...,  # (2)
) -> BatchGetItemOutputServiceResourceTypeDef:  # (3)
    ...
  1. See KeysAndAttributesServiceResourceTypeDef
  2. See ReturnConsumedCapacityType
  3. See BatchGetItemOutputServiceResourceTypeDef
# batch_get_item method usage example with argument unpacking

kwargs: BatchGetItemInputServiceResourceBatchGetItemTypeDef = {  # (1)
    "RequestItems": ...,
}

parent.batch_get_item(**kwargs)
  1. See BatchGetItemInputServiceResourceBatchGetItemTypeDef

DynamoDBServiceResource.batch_write_item method#

The BatchWriteItem operation puts or deletes multiple items in one or more tables.

Type annotations and code completion for boto3.resource("dynamodb").batch_write_item method. boto3 documentation

# batch_write_item method definition

def batch_write_item(
    self,
    *,
    RequestItems: Mapping[str, Sequence[WriteRequestServiceResourceTypeDef]],  # (1)
    ReturnConsumedCapacity: ReturnConsumedCapacityType = ...,  # (2)
    ReturnItemCollectionMetrics: ReturnItemCollectionMetricsType = ...,  # (3)
) -> BatchWriteItemOutputServiceResourceTypeDef:  # (4)
    ...
  1. See WriteRequestServiceResourceTypeDef
  2. See ReturnConsumedCapacityType
  3. See ReturnItemCollectionMetricsType
  4. See BatchWriteItemOutputServiceResourceTypeDef
# batch_write_item method usage example with argument unpacking

kwargs: BatchWriteItemInputServiceResourceBatchWriteItemTypeDef = {  # (1)
    "RequestItems": ...,
}

parent.batch_write_item(**kwargs)
  1. See BatchWriteItemInputServiceResourceBatchWriteItemTypeDef

DynamoDBServiceResource.create_table method#

The CreateTable operation adds a new table to your account.

Type annotations and code completion for boto3.resource("dynamodb").create_table method. boto3 documentation

# create_table method definition

def create_table(
    self,
    *,
    AttributeDefinitions: Sequence[AttributeDefinitionTypeDef],  # (1)
    TableName: str,
    KeySchema: Sequence[KeySchemaElementTypeDef],  # (2)
    LocalSecondaryIndexes: Sequence[LocalSecondaryIndexTypeDef] = ...,  # (3)
    GlobalSecondaryIndexes: Sequence[GlobalSecondaryIndexTypeDef] = ...,  # (4)
    BillingMode: BillingModeType = ...,  # (5)
    ProvisionedThroughput: ProvisionedThroughputTypeDef = ...,  # (6)
    StreamSpecification: StreamSpecificationTypeDef = ...,  # (7)
    SSESpecification: SSESpecificationTypeDef = ...,  # (8)
    Tags: Sequence[TagTypeDef] = ...,  # (9)
    TableClass: TableClassType = ...,  # (10)
    DeletionProtectionEnabled: bool = ...,
    ResourcePolicy: str = ...,
) -> Table:
    ...
  1. See AttributeDefinitionTypeDef
  2. See KeySchemaElementTypeDef
  3. See LocalSecondaryIndexTypeDef
  4. See GlobalSecondaryIndexTypeDef
  5. See BillingModeType
  6. See ProvisionedThroughputTypeDef
  7. See StreamSpecificationTypeDef
  8. See SSESpecificationTypeDef
  9. See TagTypeDef
  10. See TableClassType
# create_table method usage example with argument unpacking

kwargs: CreateTableInputServiceResourceCreateTableTypeDef = {  # (1)
    "AttributeDefinitions": ...,
    "TableName": ...,
    "KeySchema": ...,
}

parent.create_table(**kwargs)
  1. See CreateTableInputServiceResourceCreateTableTypeDef

DynamoDBServiceResource.get_available_subresources method#

Returns a list of all the available sub-resources for this Resource.

Type annotations and code completion for boto3.resource("dynamodb").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

Table#

Type annotations and code completion for boto3.resource("dynamodb").Table class. boto3 documentation

# Table usage example

from mypy_boto3_dynamodb.service_resource import Table

def get_resource() -> Table:
    return boto3.resource("dynamodb").Table(...)

Table attributes#

Table methods#

Table.batch_writer method#

Create a batch writer object.

Type annotations and code completion for boto3.resource("dynamodb").batch_writer method. boto3 documentation

# batch_writer method definition

def batch_writer(
    self,
    overwrite_by_pkeys: List[str] = ...,
) -> BatchWriter:
    ...
# batch_writer method usage example with argument unpacking

kwargs: TableBatchWriterRequestTypeDef = {  # (1)
    "overwrite_by_pkeys": ...,
}

parent.batch_writer(**kwargs)
  1. See TableBatchWriterRequestTypeDef

Table.delete method#

The DeleteTable operation deletes a table and all of its items.

Type annotations and code completion for boto3.resource("dynamodb").delete method. boto3 documentation

# delete method definition

def delete(
    self,
) -> DeleteTableOutputTableTypeDef:  # (1)
    ...
  1. See DeleteTableOutputTableTypeDef

Table.delete_item method#

Deletes a single item in a table by primary key.

Type annotations and code completion for boto3.resource("dynamodb").delete_item method. boto3 documentation

# delete_item method definition

def delete_item(
    self,
    *,
    Key: Mapping[str, Union[bytes, bytearray, str, int, Decimal, bool, Set[int], Set[Decimal], Set[str], Set[bytes], Set[bytearray], Sequence[Any], Mapping[str, Any], None]],
    Expected: Mapping[str, ExpectedAttributeValueTableTypeDef] = ...,  # (1)
    ConditionalOperator: ConditionalOperatorType = ...,  # (2)
    ReturnValues: ReturnValueType = ...,  # (3)
    ReturnConsumedCapacity: ReturnConsumedCapacityType = ...,  # (4)
    ReturnItemCollectionMetrics: ReturnItemCollectionMetricsType = ...,  # (5)
    ConditionExpression: Union[str, ConditionBase] = ...,
    ExpressionAttributeNames: Mapping[str, str] = ...,
    ExpressionAttributeValues: Mapping[str, Union[bytes, bytearray, str, int, Decimal, bool, Set[int], Set[Decimal], Set[str], Set[bytes], Set[bytearray], Sequence[Any], Mapping[str, Any], None]] = ...,
    ReturnValuesOnConditionCheckFailure: ReturnValuesOnConditionCheckFailureType = ...,  # (6)
) -> DeleteItemOutputTableTypeDef:  # (7)
    ...
  1. See ExpectedAttributeValueTableTypeDef
  2. See ConditionalOperatorType
  3. See ReturnValueType
  4. See ReturnConsumedCapacityType
  5. See ReturnItemCollectionMetricsType
  6. See ReturnValuesOnConditionCheckFailureType
  7. See DeleteItemOutputTableTypeDef
# delete_item method usage example with argument unpacking

kwargs: DeleteItemInputTableDeleteItemTypeDef = {  # (1)
    "Key": ...,
}

parent.delete_item(**kwargs)
  1. See DeleteItemInputTableDeleteItemTypeDef

Table.get_available_subresources method#

Returns a list of all the available sub-resources for this Resource.

Type annotations and code completion for boto3.resource("dynamodb").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

Table.get_item method#

The GetItem operation returns a set of attributes for the item with the given primary key.

Type annotations and code completion for boto3.resource("dynamodb").get_item method. boto3 documentation

# get_item method definition

def get_item(
    self,
    *,
    Key: Mapping[str, Union[bytes, bytearray, str, int, Decimal, bool, Set[int], Set[Decimal], Set[str], Set[bytes], Set[bytearray], Sequence[Any], Mapping[str, Any], None]],
    AttributesToGet: Sequence[str] = ...,
    ConsistentRead: bool = ...,
    ReturnConsumedCapacity: ReturnConsumedCapacityType = ...,  # (1)
    ProjectionExpression: str = ...,
    ExpressionAttributeNames: Mapping[str, str] = ...,
) -> GetItemOutputTableTypeDef:  # (2)
    ...
  1. See ReturnConsumedCapacityType
  2. See GetItemOutputTableTypeDef
# get_item method usage example with argument unpacking

kwargs: GetItemInputTableGetItemTypeDef = {  # (1)
    "Key": ...,
}

parent.get_item(**kwargs)
  1. See GetItemInputTableGetItemTypeDef

Table.load method#

Calls 🇵🇾meth:DynamoDB.Client.describe_table to update the attributes of the Table resource.

Type annotations and code completion for boto3.resource("dynamodb").load method.