Skip to main content

expansions/list_dynamodb_rows.py

1import boto3
4def scan_table(sess: boto3.Session, *, TableName: str, **kwargs):
5 """
6 Generates all the items in a DynamoDB table.
8 :param dynamo_client: A boto3 client for DynamoDB.
9 :param TableName: The name of the table to scan.
11 Other keyword arguments will be passed directly to the Scan operation.
12 See https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Client.scan
14 """
15 dynamo_client = sess.resource("dynamodb").meta.client
16 paginator = dynamo_client.get_paginator("scan")
18 for page in paginator.paginate(TableName=TableName, **kwargs):
19 yield from page["Items"]