Koa*_*orm 15 amazon-dynamodb boto3
我需要使用boto3更新我的dynamodb表中的timestamp属性,但属性名称"timestamp"是一个保留字,因此它在SET命令上抛出错误.
table.update_item(
Key={
'id': item_id
},
UpdateExpression='SET timestamp = :val1', # this is the line giving the problem
ExpressionAttributeValues={
":val1": new_timestamp
}
)
Run Code Online (Sandbox Code Playgroud)
"errorMessage":"调用UpdateItem操作时发生错误(ValidationException):无效的UpdateExpression:属性名称是保留关键字;保留关键字:timestamp",
Mik*_*scu 51
您可以使用表达式属性名称解决此问题(类似于您已在使用的ExpressionAttributeValues).
table.update_item(
Key={
'id': item_id
},
UpdateExpression='SET #ts = :val1',
ExpressionAttributeValues={
":val1": new_timestamp
},
ExpressionAttributeNames={
"#ts": "timestamp"
}
)
Run Code Online (Sandbox Code Playgroud)
在这里阅读所有相关内容:https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html
| 归档时间: |
|
| 查看次数: |
5820 次 |
| 最近记录: |