<p>参数<transaction>2中需要修改</p>
<p>json中的操作应该重新安排</p>
<p>在输入操作中将<strong>键</strong>替换为<strong>项</strong></p>
<pre><code>response = dynamo_client.transact_write_items(
TransactItems=[
{
'ConditionCheck': {
'Key': {
'indicator_id': {
'S': 'indicator_1'
}
},
'ConditionExpression': 'attribute_exists(#indicator_id)',
'ExpressionAttributeNames': {
'#indicator_id': 'indicator_id'
},
'TableName': 'CAS'
}
},
{
'Put': {
'Item': {
'indicator_id': {
'S': 'insert_indicator_2'
}
},
'TableName': 'CAS'
}
}
]
)
</code></pre>
<p>在文档(<a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Client.transact_write_items" rel="nofollow noreferrer">https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Client.transact_write_items</a>)中,即使所有操作都在同一个dict中提到,但仅供参考,应视为Check或Put or等</p>
<p>操作应该是这样的dict的数组(列表)</p>