使用 boto3 扫描 DynamoDB
Scan DynamoDB with boto3
我目前正在尝试扫描整个 DynamoDB table 并寻找特定属性下的特定值。如果这些值与我要查找的值匹配,我希望我的 python 代码删除整个 DynamoDB 项目。到目前为止,我目前有:
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('name-of-table-here')
response = table.scan()
data = response['Items']
我想要这样的东西:
for item in data:
if valueOfAttribute == value_being_searched:
delete DynamoDB item
else:
pass
不知道该怎么做。任何建议表示赞赏,谢谢!
我能够按照之前评论中的建议使用 FilterExpression 成功解决此问题。
这是我想出的:
import boto3
from boto3.dynamodb.conditions import Key
fe = Key('attribute').eq('value')
response = table.scan(
FilterExpression=fe)
data = response['Items']
我目前正在尝试扫描整个 DynamoDB table 并寻找特定属性下的特定值。如果这些值与我要查找的值匹配,我希望我的 python 代码删除整个 DynamoDB 项目。到目前为止,我目前有:
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('name-of-table-here')
response = table.scan()
data = response['Items']
我想要这样的东西:
for item in data:
if valueOfAttribute == value_being_searched:
delete DynamoDB item
else:
pass
不知道该怎么做。任何建议表示赞赏,谢谢!
我能够按照之前评论中的建议使用 FilterExpression 成功解决此问题。
这是我想出的:
import boto3
from boto3.dynamodb.conditions import Key
fe = Key('attribute').eq('value')
response = table.scan(
FilterExpression=fe)
data = response['Items']