DynamoDB Batch Update

There is no batch update item API available in DynamoDB at the moment.

DynamoDB API operations list


I know this is an old question by now, but DynamoDB recently added a Transaction api which supports update:

Update — Initiates an UpdateItem operation to edit an existing item's attributes or add a new item to the table if it does not already exist. Use this action to add, delete, or update attributes on an existing item conditionally or without a condition.

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/transaction-apis.html


With PartiQL you can execute batch insert and update just like SQL.

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.multiplestatements.batching.html


I reached this thread on similar query, hope this might help.

DynamoDB supports Batch Statement Execution which is described in documentation. This works with client object rather than resource object. Then I used the PartiQL update statement supported by DynamoDB and described here.

Python code reference looks something like this:

client = boto3.client('dynamodb')

batch = ["UPDATE users SET active='N' WHERE email='<user_email>' RETURNING [ALL|MODIFIED] [NEW|OLD] *;", "UPDATE users ..."]  # Limit to 25 per batch
request_items = [{'Statement': _stat} for _stat in batch]
batch_response = client.batch_execute_statement(Statements=request_items)

This is minimal code. You can use multi-threading to execute multiple batches at once.


BatchWriteItem cannot update items. To update items, use the UpdateItem action. BatchWriteItem operation puts or deletes multiple items in one or more tables

Reference: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html