Skip to content

Instantly share code, notes, and snippets.

@alanwill
Created August 21, 2016 08:59
Show Gist options
  • Save alanwill/1b9b555bbd26e91ee0c98b1e70a94423 to your computer and use it in GitHub Desktop.
Save alanwill/1b9b555bbd26e91ee0c98b1e70a94423 to your computer and use it in GitHub Desktop.
Delete Multiple DynamoDB rows
import boto3
getCleanTable = taskStatus.query(
KeyConditionExpression=Key('requestId').eq('a3248585-8ac0-4889-b1fb-976d9113f7f2') & Key('eventTimestamp').gt('1')
)
for i in getCleanTable['Items']:
cleanupTable = boto3.client('dynamodb').batch_write_item(
RequestItems={
'talr-taskStatus': [
{
'DeleteRequest': {
'Key': {
'requestId': { 'S': i['requestId'] },
'eventTimestamp': { 'S': i['eventTimestamp'] }
}
}
}
]
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment