types-aiobotocore-dynamodb Type Stubs

3.4.0 · active · verified Fri Apr 10

This library provides type annotations (stubs) for `aiobotocore`'s DynamoDB service, enhancing static analysis tools like MyPy and IDE autocompletion for asynchronous AWS interactions. Currently at version 3.4.0, it is actively maintained with frequent updates tied to `aiobotocore` and `mypy-boto3-builder` releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `types-aiobotocore-dynamodb` to get type hints for an `aiobotocore` DynamoDB client, then list tables in your AWS account. It leverages `aiobotocore`'s automatic credential discovery.

import asyncio
import os
from aiobotocore.session import get_session
from types_aiobotocore_dynamodb.client import DynamoDBClient

async def list_dynamodb_tables():
    # aiobotocore automatically picks up credentials from environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)
    # or ~/.aws/credentials and ~/.aws/config
    session = get_session()
    async with session.create_client("dynamodb", region_name=os.environ.get('AWS_REGION', 'us-east-1')) as client:
        client: DynamoDBClient # Explicit type hint for static analysis
        print(f"Listing DynamoDB tables in {client.meta.region_name}...")
        response = await client.list_tables()
        tables = response.get("TableNames", [])
        if tables:
            print("Found tables:", ", ".join(tables))
        else:
            print("No tables found.")

if __name__ == "__main__":
    # Ensure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_REGION are set in your environment
    # For a runnable example, you might need valid AWS credentials configured.
    # Example placeholder: os.environ['AWS_REGION'] = 'us-east-1'
    asyncio.run(list_dynamodb_tables())

view raw JSON →