【问题标题】:Is it possible to update my partition key if I don't have a sort key in DynamoDB?如果我在 DynamoDB 中没有排序键,是否可以更新我的分区键?
【发布时间】:2022-01-01 22:47:17
【问题描述】:

我正在尝试在 aws 中使用 python 更新我的分区键,但我真的不知道是否可以更新它?

def modifyItem(URL_ADDRESS, updateKey, updateValue):
    try:
        response = table.update_item(
                        Key={
                        'URL_ADDRESS': URL_ADDRESS
                        },
                        UpdateExpression='set %s = :value' % updateKey,
                        ExpressionAttributeValues={
                                ':value':updateValue
                        },
                        ReturnValues='UPDATED_NEW'
        )
        body = {
            'Operation': 'UPDATE',
            'Message': 'SUCCESS',
            'UpdatedAttributes': response
        }
        return buildResponse(200, body)

【问题讨论】:

标签: python amazon-web-services amazon-dynamodb crud


【解决方案1】:

您无法更新项目的主键(其分区键或排序键)。您必须插入新项目并删除旧项目。

Is it possible to update a hash key in amazon dynamo db

【讨论】:

    猜你喜欢
    • 2021-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-23
    相关资源
    最近更新 更多