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
DynamoDB GetItem Example in Node.js (AWS SDK v3)
Read a DynamoDB item by its primary key in Node.js with AWS SDK v3 — a runnable GetItemCommand example with the client, key marshalling, and the response shape.
DynamoDB GetItem Example in Python (boto3)
Read a DynamoDB item by its primary key in Python with boto3 — a runnable get_item example using the low-level client and the DynamoDB JSON key format.
DynamoDB GetItem Example with the AWS CLI
Read a DynamoDB item by its primary key from the AWS CLI — a runnable get-item command with the DynamoDB JSON key format, projection, and consistent-read flag.
DynamoDB GetItem Example in Java (AWS SDK v2)
Read a DynamoDB item by its primary key in Java with AWS SDK v2 — a runnable GetItemRequest example with AttributeValue builders and the response check.
DynamoDB GetItem Example in Go (AWS SDK v2)
Read a single DynamoDB item by its primary key in Go with AWS SDK v2 — a runnable GetItem example with typed attribute values and the nil-Item check.
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
DynamoDB BatchGetItem in Node.js (AWS SDK v3)
Read up to 100 DynamoDB items in one call in Node.js with AWS SDK v3 — a runnable BatchGetItemCommand example with an UnprocessedKeys retry loop and backoff.
DynamoDB BatchGetItem Example in Python (boto3)
Read up to 100 DynamoDB items in one call with Python and boto3 — a runnable batch_get_item example with an UnprocessedKeys retry loop and exponential backoff.
DynamoDB BatchGetItem Example with the AWS CLI
Read up to 100 DynamoDB items in one command — a runnable aws dynamodb batch-get-item example with the request-items format and the UnprocessedKeys re-run step.
DynamoDB BatchWriteItem in Node.js (AWS SDK v3)
Write or delete up to 25 DynamoDB items in one Node.js call — a runnable BatchWriteItemCommand example with an UnprocessedItems retry loop.
DynamoDB Batch Write in Python (batch_writer)
Bulk-write DynamoDB items in Python — a runnable boto3 batch_writer() example that batches into 25s and retries unprocessed items for you.
DynamoDB BatchWriteItem Example with the AWS CLI
Write or delete up to 25 DynamoDB items in one AWS CLI command — a runnable batch-write-item example with the UnprocessedItems re-run.
Transactions
DynamoDB TransactWriteItems in Node.js (SDK v3)
Write multiple DynamoDB items atomically in Node.js with AWS SDK v3 — a runnable TransactWriteItemsCommand example with CancellationReasons.
DynamoDB TransactWriteItems in Python (boto3)
Write multiple DynamoDB items atomically in Python with boto3 — a runnable transact_write_items example with conditions and CancellationReasons.
DynamoDB TransactWriteItems with the AWS CLI
Write multiple DynamoDB items atomically from the AWS CLI — a runnable transact-write-items example with conditions and cancellation reasons.
More DynamoDB resources
Learn DynamoDB
A structured DynamoDB curriculum, from the fundamentals through to the internals.
DynamoDB vs Other Databases
How DynamoDB compares to MongoDB, PostgreSQL, Cassandra, Aurora and more.
Common DynamoDB Errors
Every common DynamoDB error with its cause and the exact fix.
DynamoDB FAQ
Straight answers to the DynamoDB questions developers ask most.
Engineering Blog
How DynoTable is built — the stories behind the AI agent and the MCP server.
DynamoDB Tools
Expression builder, pricing and capacity calculators — right in your browser.
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.