Created
November 15, 2024 01:03
-
-
Save mark-cooper/9a121e3647b154ad89a829fa078f15b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
dynamodb = boto3.resource('dynamodb') | |
table = dynamodb.Table('TABLE_NAME') | |
def update_items(items): | |
for item in items: | |
table.update_item( | |
Key={ | |
'KEY': item['KEY'] | |
}, | |
UpdateExpression="SET FIELD = :val", | |
ExpressionAttributeValues={ | |
':val': 'VALUE' | |
} | |
) | |
response = table.scan() | |
update_items(response['Items']) | |
while 'LastEvaluatedKey' in response: | |
response = table.scan(ExclusiveStartKey=response['LastEvaluatedKey']) | |
update_items(response['Items']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment