Guido
Guido

Reputation: 1

add string array values into dynamo db

I'm trying to use put_item to add an array of strings into dynamodb.

This is the code that I wrote:

table = dynamodb.Table('variables')
string = [first line, second line, third line]

table.put_item(
    Item = {
        "variables": { "SS": [ string ]}
    }
)

But I'm getting the following error:

"errorMessage": "An error occurred (ValidationException) when calling the PutItem operation: One or more parameter values were invalid: Missing the key strings in the item"

I've tried reading through the documentation but without luck.

Upvotes: 0

Views: 1528

Answers (1)

alexis-donoghue
alexis-donoghue

Reputation: 3387

If you use Table resource, you don't need to specify DynamoDB types like SS. Just put your item into dict, otherwise you will see these types being interpreted as actual data.

There is a bit of confusion between client.put_item() which expects raw data with types, and Table.put_item() which expects regular dict. Whenever possible, use table one.

In your case it should look something like table.put_item(Item = {"variables": string})

Upvotes: 0

Related Questions