Skip to content

Examples#

Index > DynamoDB > Examples

Auto-generated documentation for DynamoDB type annotations stubs module types-aiobotocore-dynamodb.

Client#

Implicit type annotations#

Can be used with types-aiobotocore[dynamodb] package installed.

Write your DynamoDB code as usual, type checking and code completion should work out of the box.

# DynamoDBClient usage example

from aiobotocore.session import get_session


session = get_session()

async with session.create_client("dynamodb") as client:  # (1)
    result = await client.batch_execute_statement()  # (2)
  1. client: DynamoDBClient
  2. result: BatchExecuteStatementOutputTypeDef
# ListBackupsPaginator usage example

from aiobotocore.session import get_session


session = get_session()

async with session.create_client("dynamodb") as client:  # (1)
    paginator = client.get_paginator("list_backups")  # (2)
    async for item in paginator.paginate(...):
        print(item)  # (3)
  1. client: DynamoDBClient
  2. paginator: ListBackupsPaginator
  3. item: ListBackupsOutputTypeDef
# TableExistsWaiter usage example

from aiobotocore.session import get_session


session = get_session()

async with session.create_client("dynamodb") as client:  # (1)
    waiter = client.get_waiter("table_exists")  # (2)
    await waiter.wait()
  1. client: DynamoDBClient
  2. waiter: TableExistsWaiter

Explicit type annotations#

With types-aiobotocore-lite[dynamodb] or a standalone types_aiobotocore_dynamodb package, you have to explicitly specify client: DynamoDBClient type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

# DynamoDBClient usage example with type annotations

from aiobotocore.session import get_session

from types_aiobotocore_dynamodb.client import DynamoDBClient
from types_aiobotocore_dynamodb.type_defs import BatchExecuteStatementOutputTypeDef
from types_aiobotocore_dynamodb.type_defs import BatchExecuteStatementInputRequestTypeDef


session = get_session()

async with session.create_client("dynamodb") as client:
    client: DynamoDBClient
    kwargs: BatchExecuteStatementInputRequestTypeDef = {...}
    result: BatchExecuteStatementOutputTypeDef = await client.batch_execute_statement(**kwargs)
# ListBackupsPaginator usage example with type annotations

from aiobotocore.session import get_session

from types_aiobotocore_dynamodb.client import DynamoDBClient
from types_aiobotocore_dynamodb.paginator import ListBackupsPaginator
from types_aiobotocore_dynamodb.type_defs import ListBackupsOutputTypeDef


session = get_session()

async with session.create_client("dynamodb") as client:
    client: DynamoDBClient
    paginator: ListBackupsPaginator = client.get_paginator("list_backups")
    async for item in paginator.paginate(...):
        item: ListBackupsOutputTypeDef
        print(item)
# TableExistsWaiter usage example with type annotations

from aiobotocore.session import get_session

from types_aiobotocore_dynamodb.client import DynamoDBClient
from types_aiobotocore_dynamodb.waiter import TableExistsWaiter


session = get_session()

async with session.create_client("dynamodb") as client:
    client: DynamoDBClient
    waiter: TableExistsWaiter = client.get_waiter("table_exists")
    await waiter.wait()