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

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

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

Method definition
def Table(
    self,
    name: str,
) -> Table:
    ...
Usage example with kwargs
kwargs: ServiceResourceTableRequestTypeDef = {  # (1)
    "name": ...,
}

parent.Table(**kwargs)
  1. See ServiceResourceTableRequestTypeDef

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

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
Usage example with kwargs
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

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
Usage example with kwargs
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

Method definition
def create_table(
    self,
    *,
    AttributeDefinitions: Sequence[AttributeDefinitionServiceResourceTypeDef],  # (1)
    TableName: str,
    KeySchema: Sequence[KeySchemaElementServiceResourceTypeDef],  # (2)
    LocalSecondaryIndexes: Sequence[LocalSecondaryIndexServiceResourceTypeDef] = ...,  # (3)
    GlobalSecondaryIndexes: Sequence[GlobalSecondaryIndexServiceResourceTypeDef] = ...,  # (4)
    BillingMode: BillingModeType = ...,  # (5)
    ProvisionedThroughput: ProvisionedThroughputServiceResourceTypeDef = ...,  # (6)
    StreamSpecification: StreamSpecificationServiceResourceTypeDef = ...,  # (7)
    SSESpecification: SSESpecificationServiceResourceTypeDef = ...,  # (8)
    Tags: Sequence[TagServiceResourceTypeDef] = ...,  # (9)
    TableClass: TableClassType = ...,  # (10)
    DeletionProtectionEnabled: bool = ...,
) -> Table:
    ...
  1. See AttributeDefinitionServiceResourceTypeDef
  2. See KeySchemaElementServiceResourceTypeDef
  3. See LocalSecondaryIndexServiceResourceTypeDef
  4. See GlobalSecondaryIndexServiceResourceTypeDef
  5. See BillingModeType
  6. See ProvisionedThroughputServiceResourceTypeDef
  7. See StreamSpecificationServiceResourceTypeDef
  8. See SSESpecificationServiceResourceTypeDef
  9. See TagServiceResourceTypeDef
  10. See TableClassType
Usage example with kwargs
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

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

Table

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

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

Method definition
def batch_writer(
    self,
    overwrite_by_pkeys: List[str] = ...,
) -> BatchWriter:
    ...
Usage example with kwargs
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

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

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]] = ...,
) -> DeleteItemOutputTableTypeDef:  # (6)
    ...
  1. See ExpectedAttributeValueTableTypeDef
  2. See ConditionalOperatorType
  3. See ReturnValueType
  4. See ReturnConsumedCapacityType
  5. See ReturnItemCollectionMetricsType
  6. See DeleteItemOutputTableTypeDef
Usage example with kwargs
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

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

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
Usage example with kwargs
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. boto3 documentation

Method definition
def load(
    self,
) -> None:
    ...

Table.put_item method

Creates a new item, or replaces an old item with a new item.

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

Method definition
def put_item(
    self,
    *,
    Item: 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)
    ReturnValues: ReturnValueType = ...,  # (2)
    ReturnConsumedCapacity: ReturnConsumedCapacityType = ...,  # (3)
    ReturnItemCollectionMetrics: ReturnItemCollectionMetricsType = ...,  # (4)
    ConditionalOperator: ConditionalOperatorType = ...,  # (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]] = ...,
) -> PutItemOutputTableTypeDef:  # (6)
    ...
  1. See ExpectedAttributeValueTableTypeDef
  2. See ReturnValueType
  3. See ReturnConsumedCapacityType
  4. See ReturnItemCollectionMetricsType
  5. See ConditionalOperatorType
  6. See PutItemOutputTableTypeDef
Usage example with kwargs
kwargs: PutItemInputTablePutItemTypeDef = {  # (1)
    "Item": ...,
}

parent.put_item(**kwargs)
  1. See PutItemInputTablePutItemTypeDef

Table.query method

You must provide the name of the partition key attribute and a single value for that attribute.

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

Method definition
def query(
    self,
    *,
    IndexName: str = ...,
    Select: SelectType = ...,  # (1)
    AttributesToGet: Sequence[str] = ...,
    Limit: int = ...,
    ConsistentRead: bool = ...,
    KeyConditions: Mapping[str, ConditionTableTypeDef] = ...,  # (2)
    QueryFilter: Mapping[str, ConditionTableTypeDef] = ...,  # (2)
    ConditionalOperator: ConditionalOperatorType = ...,  # (4)
    ScanIndexForward: bool = ...,
    ExclusiveStartKey: 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]] = ...,
    ReturnConsumedCapacity: ReturnConsumedCapacityType = ...,  # (5)
    ProjectionExpression: str = ...,
    FilterExpression: Union[str, ConditionBase] = ...,
    KeyConditionExpression: 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]] = ...,
) -> QueryOutputTableTypeDef:  # (6)
    ...
  1. See SelectType
  2. See ConditionTableTypeDef
  3. See ConditionTableTypeDef
  4. See ConditionalOperatorType
  5. See ReturnConsumedCapacityType
  6. See QueryOutputTableTypeDef
Usage example with kwargs
kwargs: QueryInputTableQueryTypeDef = {  # (1)
    "IndexName": ...,
}

parent.query(**kwargs)
  1. See QueryInputTableQueryTypeDef

Table.reload method

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

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

Method definition
def reload(
    self,
) -> None:
    ...

Table.scan method

The Scan operation returns one or more items and item attributes by accessing every item in a table or a secondary index.

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

Method definition
def scan(
    self,
    *,
    IndexName: str = ...,
    AttributesToGet: Sequence[str] = ...,
    Limit: int = ...,
    Select: SelectType = ...,  # (1)
    ScanFilter: Mapping[str, ConditionTableTypeDef] = ...,  # (2)
    ConditionalOperator: ConditionalOperatorType = ...,  # (3)
    ExclusiveStartKey: 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]] = ...,
    ReturnConsumedCapacity: ReturnConsumedCapacityType = ...,  # (4)
    TotalSegments: int = ...,
    Segment: int = ...,
    ProjectionExpression: str = ...,
    FilterExpression: 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]] = ...,
    ConsistentRead: bool = ...,
) -> ScanOutputTableTypeDef:  # (5)
    ...
  1. See SelectType
  2. See ConditionTableTypeDef
  3. See ConditionalOperatorType
  4. See ReturnConsumedCapacityType
  5. See ScanOutputTableTypeDef
Usage example with kwargs
kwargs: ScanInputTableScanTypeDef = {  # (1)
    "IndexName": ...,
}

parent.scan(**kwargs)
  1. See ScanInputTableScanTypeDef

Table.update method

Modifies the provisioned throughput settings, global secondary indexes, or DynamoDB Streams settings for a given table.

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

Method definition
def update(
    self,
    *,
    AttributeDefinitions: Sequence[AttributeDefinitionTableTypeDef] = ...,  # (1)
    BillingMode: BillingModeType = ...,  # (2)
    ProvisionedThroughput: ProvisionedThroughputTableTypeDef = ...,  # (3)
    GlobalSecondaryIndexUpdates: Sequence[GlobalSecondaryIndexUpdateTableTypeDef] = ...,  # (4)
    StreamSpecification: StreamSpecificationTableTypeDef = ...,  # (5)
    SSESpecification: SSESpecificationTableTypeDef = ...,  # (6)
    ReplicaUpdates: Sequence[ReplicationGroupUpdateTableTypeDef] = ...,  # (7)
    TableClass: TableClassType = ...,  # (8)
    DeletionProtectionEnabled: bool = ...,
) -> Table:
    ...
  1. See AttributeDefinitionTableTypeDef
  2. See BillingModeType
  3. See ProvisionedThroughputTableTypeDef
  4. See GlobalSecondaryIndexUpdateTableTypeDef
  5. See StreamSpecificationTableTypeDef
  6. See SSESpecificationTableTypeDef
  7. See ReplicationGroupUpdateTableTypeDef
  8. See TableClassType
Usage example with kwargs
kwargs: UpdateTableInputTableUpdateTypeDef = {  # (1)
    "AttributeDefinitions": ...,
}

parent.update(**kwargs)
  1. See UpdateTableInputTableUpdateTypeDef

Table.update_item method

Edits an existing item's attributes, or adds a new item to the table if it does not already exist.

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

Method definition
def update_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]],
    AttributeUpdates: Mapping[str, AttributeValueUpdateTableTypeDef] = ...,  # (1)
    Expected: Mapping[str, ExpectedAttributeValueTableTypeDef] = ...,  # (2)
    ConditionalOperator: ConditionalOperatorType = ...,  # (3)
    ReturnValues: ReturnValueType = ...,  # (4)
    ReturnConsumedCapacity: ReturnConsumedCapacityType = ...,  # (5)
    ReturnItemCollectionMetrics: ReturnItemCollectionMetricsType = ...,  # (6)
    UpdateExpression: str = ...,
    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]] = ...,
) -> UpdateItemOutputTableTypeDef:  # (7)
    ...
  1. See AttributeValueUpdateTableTypeDef
  2. See ExpectedAttributeValueTableTypeDef
  3. See ConditionalOperatorType
  4. See ReturnValueType
  5. See ReturnConsumedCapacityType
  6. See ReturnItemCollectionMetricsType
  7. See UpdateItemOutputTableTypeDef
Usage example with kwargs
kwargs: UpdateItemInputTableUpdateItemTypeDef = {  # (1)
    "Key": ...,
}

parent.update_item(**kwargs)
  1. See UpdateItemInputTableUpdateItemTypeDef

Table.wait_until_exists method

Waits until this Table is exists.

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

Method definition
def wait_until_exists(
    self,
) -> None:
    ...

Table.wait_until_not_exists method

Waits until this Table is not exists.

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

Method definition
def wait_until_not_exists(
    self,
) -> None:
    ...