AWS Update Item error UpdateItem操作:提供的键元素与架构不匹配

2024-04-26 00:42:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试更新AWS中有两个键的dynamodb表。一列“col1”是哈希键,列“col2”是范围键。它没有GSIs。你知道吗

除了col1和col2之外,还有两列col3和col4不是索引,但它们有一个值。你知道吗

所有4列都是String类型,包括索引。你知道吗

我正在尝试用下面的代码创建一个新列col5,并收到以下错误消息“调用UpdateItem操作时发生错误(ValidationException):提供的key元素与架构不匹配”

response = table.update_item(
        Key={
            'col1': col1_var,
            'col2': col2_var
        },
        UpdateExpression="SET col5 = :col5_var, col6 = :col6_var",                   
        ExpressionAttributeValues={
            ':col5_var': str(datetime.datetime.now()),
            ':col6_var': post_api_response
            }
    )

Tags: aws类型datetimestringresponsevar错误dynamodb