DynamoDB code examples

DynamoDB Code Examples — Copy-Paste Snippets

Ready-to-run DynamoDB snippets for every operation and language — copy, adapt, and build it visually with the Expression Builder.

Reading items

Writing items

DynamoDB PutItem Example in Node.js (AWS SDK v3)
Write a DynamoDB item in Node.js with AWS SDK v3 — a runnable PutItemCommand example with a ConditionExpression that prevents overwrites.
DynamoDB PutItem Example in Python (boto3)
Write a DynamoDB item in Python with boto3 — a runnable put_item example with DynamoDB JSON attributes and a ConditionExpression to prevent overwrites.
DynamoDB PutItem Example with the AWS CLI
Write a DynamoDB item from the AWS CLI — a runnable put-item command with the DynamoDB JSON format and a condition-expression that blocks overwrites.
DynamoDB PutItem Example in Java (AWS SDK v2)
Write a DynamoDB item in Java with AWS SDK v2 — a runnable PutItemRequest example with typed AttributeValue builders and a ConditionExpression.
DynamoDB PutItem Example in Go (AWS SDK v2)
Write a DynamoDB item in Go with AWS SDK v2 — a complete, runnable PutItem example with typed attribute values and a ConditionExpression handled via errors.As.
DynamoDB UpdateItem in Node.js (AWS SDK v3)
Update a DynamoDB item in Node.js with AWS SDK v3 — a runnable UpdateItemCommand example with SET, an atomic counter, ReturnValues, and reserved-word aliases.
DynamoDB UpdateItem Example in Python (boto3)
Update a DynamoDB item in Python with boto3 — a complete, runnable update_item example with SET, an atomic ADD counter, ReturnValues, and reserved-word aliases.
DynamoDB UpdateItem Example with the AWS CLI
Update a DynamoDB item from the AWS CLI — a complete, runnable update-item command with SET, an atomic ADD counter, return-values, and reserved-word aliases.
DynamoDB UpdateItem Example in Java (AWS SDK v2)
Update a DynamoDB item in Java with AWS SDK v2 — a runnable UpdateItemRequest example with SET, an atomic ADD counter, ReturnValues, and reserved-word aliases.
DynamoDB UpdateItem Example in Go (AWS SDK v2)
Update a DynamoDB item in Go with AWS SDK v2 — a complete, runnable UpdateItem example with SET, an atomic ADD counter, ReturnValues, and reserved-word aliases.
DynamoDB DeleteItem Example in Java (AWS SDK v2)
Delete a DynamoDB item by its primary key in Java with AWS SDK v2 — a runnable DeleteItemRequest example with ReturnValues ALL_OLD.
DynamoDB DeleteItem Example in Go (AWS SDK v2)
Delete a DynamoDB item by its primary key in Go with AWS SDK v2 — a runnable DeleteItem example with ReturnValues ALL_OLD and conditional deletes.
DynamoDB Conditional Write in Node.js (SDK v3)
Make a DynamoDB write conditional in Node.js with AWS SDK v3 — a runnable optimistic-locking UpdateItemCommand with ConditionExpression.
DynamoDB Conditional Write in Python (boto3)
Make a DynamoDB write conditional in Python with boto3 — a runnable optimistic-locking update_item example with ConditionExpression and failed-check handling.
DynamoDB Conditional Write with the AWS CLI
Make a DynamoDB write conditional from the AWS CLI — a runnable optimistic-locking update-item command with --condition-expression.

Querying & scanning

DynamoDB Query Example in Node.js (AWS SDK v3)
Query a DynamoDB partition in Node.js with AWS SDK v3 — a runnable QueryCommand example with KeyConditionExpression, a sort-key condition, and pagination.
DynamoDB Query Example in Python (boto3)
Query a DynamoDB partition in Python with boto3 — a runnable query example with a key condition expression and the built-in query paginator.
DynamoDB Query Example with the AWS CLI
Query a DynamoDB partition from the AWS CLI — a runnable query command with key-condition-expression, expression-attribute-values, and auto-pagination.
DynamoDB Query Example in Java (AWS SDK v2)
Query a DynamoDB partition in Java with AWS SDK v2 — a runnable QueryRequest example with a key condition expression and the built-in queryPaginator.
DynamoDB Query Example in Go (AWS SDK v2)
Query a DynamoDB partition in Go with AWS SDK v2 — a runnable Query example with a key condition expression and the built-in QueryPaginator for full pagination.
DynamoDB Query a GSI in Node.js (AWS SDK v3)
Query a DynamoDB global secondary index in Node.js with AWS SDK v3 — a runnable QueryCommand example with IndexName, pagination, and the GSI consistency rules.
DynamoDB Query a GSI in Python (boto3) — Example
Query a DynamoDB global secondary index in Python with boto3 — a complete, runnable example with IndexName, the query paginator, and the GSI consistency rules.
DynamoDB Query a GSI with the AWS CLI — Example
Query a DynamoDB global secondary index from the AWS CLI — a runnable query example with --index-name and the GSI consistency rules.
DynamoDB Scan Example in Node.js (AWS SDK v3)
Scan a DynamoDB table in Node.js with AWS SDK v3 — a runnable ScanCommand example with LastEvaluatedKey pagination and why Scan is a last resort.
DynamoDB Scan Example in Python (boto3)
Scan a DynamoDB table in Python with boto3 — a runnable scan example with a filter expression, the scan paginator, and why Scan is a last resort.
DynamoDB Scan Example with the AWS CLI
Scan a DynamoDB table from the AWS CLI — a runnable scan command with filter-expression, auto-pagination, and why Scan is a last resort.
DynamoDB Scan Example in Java (AWS SDK v2)
Scan a DynamoDB table in Java with AWS SDK v2 — a runnable ScanRequest example with FilterExpression, the built-in scanPaginator, and why Scan is a last resort.
DynamoDB Scan Example in Go (AWS SDK v2)
Scan a DynamoDB table in Go with AWS SDK v2 — a runnable Scan example with FilterExpression, the built-in ScanPaginator, and why Scan is a last resort.
Get All Items from DynamoDB in Node.js (SDK v3)
Read every item in a DynamoDB table in Node.js with AWS SDK v3 — a runnable full-table Scan pagination loop, plus parallel scan and its cost.
Get All Items from DynamoDB in Python (boto3)
Read every item in a DynamoDB table in Python with boto3 — a runnable full-table scan using the built-in paginator, plus parallel scan and the cost trade-offs.
Get All Items from DynamoDB with the AWS CLI
Read every item in a DynamoDB table from the AWS CLI — a runnable aws dynamodb scan example with automatic pagination, NextToken chunking, and cost trade-offs.

Batch operations

Transactions

More DynamoDB resources

Work with DynamoDB without the Console

A fast DynamoDB desktop client that runs the real SQL DynamoDB can’t — JOINs, GROUP BY, aggregates — with visual editing and an AI agent on your own Bedrock keys.

Free 30-day trial, no credit card — then the Free plan with no time limit.