Created
May 18, 2018 06:38
-
-
Save Swalloow/9966d576a9aafff482eef6b59c222baa to your computer and use it in GitHub Desktop.
Boto3 DynamoDB delete all items
This file contains 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', 'region-name') | |
table = dynamodb.Table('table-name') | |
scan = table.scan( | |
ProjectionExpression='#k', | |
ExpressionAttributeNames={ | |
'#k': 'name' | |
} | |
) | |
with table.batch_writer() as batch: | |
for each in scan['Items']: | |
batch.delete_item(Key=each) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment