0

Here is what I got so far:

def update_status(migrationId, status):
    table = dynamodb.Table('rockar-dev-data-migration-state')
    response = table.update_item(
    Key={'migrationId': migrationId},
    AttributeUpdates={
        'state': status,
        'timeStamp': dt.now()
    }
)

This fails with an error: 'DynamoDB' object has no attribute 'Table'

I have also tried this:

def update_status(migrationId, status):
    
    response = dynamodb.update_item(
       TableName='rockar-dev-data-migration-state',
        Key={ 'migrationId': migrationId },
        UpdateExpression="set state =:st",
        ExpressionAttributeValues={
            ':st': status

        },
        ReturnValues="UPDATED_NEW"
    )
    return response

but this produces an error too: Invalid type for parameter Key.migrationId, value: 1234567, type: <class 'str'>, valid types: <class 'dict'>

How do i go about this?

Many thanks

  • Please add the code that creates the `dynamodb` variable - you're probably confusing the client and resource APIs in boto3. – Maurice Apr 14 '22 at 15:18
  • Related: [Difference in boto3 between resource, client, and session?](https://stackoverflow.com/questions/42809096/difference-in-boto3-between-resource-client-and-session) – Maurice Apr 14 '22 at 15:20

0 Answers0