Get All Items from DynamoDB in Python (boto3)

There is no "select all" in DynamoDB — reading a whole table means a scan you paginate to the end. Each response carries at most 1 MB; boto3's built-in scan paginator follows LastEvaluatedKey across every page for you.

Code

import boto3

client = boto3.client("dynamodb")

paginator = client.get_paginator("scan")

items = []
for page in paginator.paginate(TableName="Music"):
    items.extend(page["Items"])

print(f"Table holds {len(items)} items")

Explanation

  • The paginator is the point — a single scan call does NOT return the table; it returns up to 1 MB. client.get_paginator("scan") issues follow-up requests (feeding LastEvaluatedKey back as ExclusiveStartKey) until the table is exhausted — the loop people forget when they wonder why items are "missing". (Doing it by hand? Keep calling while the response contains a LastEvaluatedKey.)
  • Memoryitems holds the entire table. For big tables, process each page inside the loop (write to a file, stream, aggregate) instead of accumulating.
  • Faster on big tables: parallel scan — pass Segment=i, TotalSegments=N and run N workers (threads/processes), each paginating its own segment. Same total cost, much lower wall-clock time.
  • Cost — a full scan reads (and bills) every byte of every item, every time you run it. ProjectionExpression shrinks the response, not the bill; don't put a scan on a hot path — that's what query and access-pattern design are for.
  • Items return in DynamoDB JSON ({"S": ...}). Prefer native Python types? Use the resource API (table.scan + a manual LastEvaluatedKey loop — the resource API has no paginator).

Do it visually

Eyeballing a table doesn't need a script: download DynoTable to browse any table in a paginated grid — it pages through scans for you, no loop to get wrong. And before you scan-and-pay, the DynamoDB pricing calculator shows what a full read of your table actually costs.

References

Last verified 2026-07-13 against the official AWS documentation linked above.

Build this request visually

Compose this operation in the free DynamoDB Query Builder — key condition, filter, index, Limit, sort order, and a pagination loop — and copy it back as a runnable SDK v3, CLI, or boto3 program.

Open the DynamoDB Query Builder

Work with DynamoDB without the Console

DynoTable is a fast desktop client for DynamoDB — browse tables, run SQL-style queries, and edit items locally.