Home > Enterprise >  Is it possible to update my partition key if I don't have a sort key in DynamoDB?
Is it possible to update my partition key if I don't have a sort key in DynamoDB?

Time:01-03

I'm trying to update my partition key using python in aws but I can't really figure it out if it's even possible to update it?

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)

My Table

That's my request body

CodePudding user response:

You cannot update an item’s primary key (either its partition key or sort key). You must insert a new item and delete the old.

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

  • Related