View a markdown version of this page

Amazon DynamoDB - AWS SDK for Python v4

Developer Preview: This documentation covers the AWS SDK for Python v4, which is in Developer Preview and intended for evaluation and testing only. Do not use it for production workloads. For production applications, use the AWS SDK for Python (Boto3). To understand the differences between the two SDKs, see Choosing the right AWS SDK for Python.

Amazon DynamoDB

Amazon DynamoDB is a serverless NoSQL database service. This section has runnable examples for common DynamoDB tasks. The examples create tables, read and write items, run queries and scans, and group writes and reads in batches and transactions.

Install the aws-sdk-dynamodb package before you run the examples.

python -m pip install aws-sdk-dynamodb

Set up the examples

The examples on the following pages use a client that the following create_client() function returns. Call it in a with statement, such as with create_client() as client:, or call client.close() after the last operation, as described in Creating a service client.

Configure an AWS Region and credentials before you run the examples. For more information, see Configuration variables and Credential providers.

Imports

from aws_sdk_dynamodb import DynamoDBClient, DynamoDBConfig

Code

def create_client() -> DynamoDBClient: config = DynamoDBConfig.resolve() return DynamoDBClient(config=config)