I am currently trying to scan an entire DynamoDB table and looking for specific values under specific attributes. If those values match with what I am looking for, I want my python code to delete the entire DynamoDB item. So far, I currently have:
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('name-of-table-here')
response = table.scan()
data = response['Items']
I wanted to have something like this:
for item in data:
if valueOfAttribute == value_being_searched:
delete DynamoDB item
else:
pass
Not sure how to go about this. Any suggestions are appreciated, thank you!
I was able to successfully solve this with the FilterExpression as suggested in a previous comment.
Here is what I came up with:
import boto3
from boto3.dynamodb.conditions import Key
fe = Key('attribute').eq('value')
response = table.scan(
FilterExpression=fe)
data = response['Items']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.