尝试使用多个表达式SET和DELETE。一切都适用于SET,但是当我添加DELETE时,无法找出正确的语法。
status = "Previously Deployed version"
message = "New version deployment started"
NewVersion = "PipelineTestAPI_1.5.0"
json_ = {":val1" : status,
":val2" : message,
":val4" : NewVersion
}
dynamo_json = ast.literal_eval(d_json.dumps(json_))
json_key = {"Environment" : "PipelineTestAPI-Prod"}
dynamo_key = ast.literal_eval(d_json.dumps(json_key))
resp = dynamo.update_item(
TableName = "CICDDeployment_Tracker",
Key = dynamo_key,
UpdateExpression = "SET currentstage = : val1, message = : val2 DELETE :val4",
ExpressionAttributeValues = dynamo_json
)
print resp
错误:
无效的UpdateExpression:语法错误;令牌:“:val4”,附近:“删除 :VAL4"
答案 0 :(得分:0)
应为REMOVE
而不是DELETE
,REMOVE attributeName
不应为value
UpdateExpression = "SET currentstage = : val1, message = : val2 REMOVE newVersion",