使用多个表达式更新dynamo中的项目,无法使用SET进行删除

时间:2018-03-13 20:09:28

标签: amazon-dynamodb boto3

尝试使用多个表达式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"

1 个答案:

答案 0 :(得分:0)

应为REMOVE而不是DELETEREMOVE attributeName不应为value

UpdateExpression = "SET currentstage = : val1, message = : val2 REMOVE newVersion",