Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Lambda返回条件checkfailedexception而不是更新项_Python_Amazon Web Services_Aws Lambda_Amazon Dynamodb_Boto3 - Fatal编程技术网

Python Lambda返回条件checkfailedexception而不是更新项

Python Lambda返回条件checkfailedexception而不是更新项,python,amazon-web-services,aws-lambda,amazon-dynamodb,boto3,Python,Amazon Web Services,Aws Lambda,Amazon Dynamodb,Boto3,我试图让Lambda函数更新DynamoDB表中的结果,但我只想更新表中的现有条目/项,而不创建新项 我目前有以下情况: def updateDynamo(asset, averageRating) : updateItem = ChipRatingTable.update_item( Key={ 'AssetID': asset }, UpdateExpression="SET AverageRating = :

我试图让Lambda函数更新DynamoDB表中的结果,但我只想更新表中的现有条目/项,而不创建新项

我目前有以下情况:

def updateDynamo(asset, averageRating) : 
    updateItem = ChipRatingTable.update_item(
        Key={
            'AssetID': asset
        },
        UpdateExpression="SET AverageRating = :a",
        ConditionExpression='attribute_exists(AssetID)',
        ExpressionAttributeValues={
            ':a': Decimal(str(averageRating))
        },
        ReturnValues="UPDATED_NEW"
    ) 
我曾尝试做过一些研究,并注意到ConditionExpression是一种方法,但每次尝试时都会出现错误:

“errorMessage”:“调用UpdateItem操作时发生错误(ConditionalCheckFailedException):条件请求失败”,“errorType”:“ConditionalCheckFailedException”


任何帮助都将不胜感激!谢谢

您收到的错误是什么?感谢您的回复,这是我收到的错误:“errorMessage”:“调用UpdateItem操作时发生错误(ConditionalCheckFailedException):条件请求失败”,“errorType”:“ConditionalCheckFailedException”,您的示例代码与错误消息不符。您可能使用了ConditionExpression,但示例代码中缺少它。是的,很抱歉,对其进行了编辑,并用我实际使用的内容再次更新了它!您收到的错误是什么?感谢您的回复,这是我收到的错误:“errorMessage”:“调用UpdateItem操作时发生错误(ConditionalCheckFailedException):条件请求失败”,“errorType”:“ConditionalCheckFailedException”,您的示例代码与错误消息不符。您可能使用了ConditionExpression,但示例代码中缺少它。是的,很抱歉,对其进行了编辑,并用我实际使用的内容再次更新了它!