Skip to content

Instantly share code, notes, and snippets.

@Swalloow
Created May 18, 2018 06:38
Show Gist options
  • Save Swalloow/9966d576a9aafff482eef6b59c222baa to your computer and use it in GitHub Desktop.
Save Swalloow/9966d576a9aafff482eef6b59c222baa to your computer and use it in GitHub Desktop.
Boto3 DynamoDB delete all items
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