Created
December 17, 2016 05:35
-
-
Save sunnycyk/02e2367004c7ade0f65eebc39fb97159 to your computer and use it in GitHub Desktop.
dynamodb notes
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') | |
response = table.scan( | |
ProjectionExpression='#k,#s', | |
ExpressionAttributeNames={ | |
'#k' : 'id', #partition key | |
'#s' : 'sortkey' #sort key | |
} | |
) | |
items = response['Items'] | |
for item in items: | |
response = table.update_item( | |
Key=item, | |
UpdateExpression='SET #s = :status, #d = :del', | |
ExpressionAttributeNames={ | |
'#s' : 'status', | |
'#d' : 'deleted' | |
}, | |
ExpressionAttributeValues={ | |
':status' : 'live', | |
':del' : False | |
} | |
) |
@andresvia no. You need to check if LastEvaluatedKey
is in the scan response
to know if the results have been paginated. Then the last evaluated key should be provided in the next scan as ExclusiveStartKey
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @sunnycyk does this take care of pagination?