[英]Boto3 DynamoDB update list attributes for an item
I have a table like: 我有一张像这样的桌子:
{
"pKey": 10001,
"items": [
{
"name": "A",
"value": 100
},
{
"name": "B",
"value": 100
}
]
}
I would like to update all value
attributes in items
list to be 200, items
list can have 1 to n objects. 我想将items
列表中的所有value
属性更新为200, items
列表可以具有1到n个对象。
How can I do that using boto3 python dynamoDB low-level client APIs? 如何使用boto3 python dynamoDB低级客户端API做到这一点?
I haven't really tested this but this is what I can come up just by reading the docs : 我还没有真正测试过,但这就是我可以通过阅读文档得出的结果:
import boto3
ddb = boto3.resource('dynamodb')
table = ddb.Table('your_table')
document = table.get_item(Key={'pKey': 10001})['Item']
for item in document['items']:
item['value'] = 200
table.put_item(Item=document, ReturnValues='NONE')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.