I would like to add an item to my DynamoDB table via command line, but I've run into a type error.
The data that I'm trying to add is very simple:
{ "id": "1" }
The command I'm running is equally simple:
aws dynamodb put-item --table-name my_table --item '{ "id": "1" }'
The error I'm getting is:
Invalid type for parameter Item.id, value: 1, type: <type 'unicode'>, valid types: <type 'dict'>
I come from a JavaScript background, so I'm not familiar with dict
types. From what I understand from some of the sources I've read, this is a Python thing? How do I change my data into something that DynamoDB can handle?
Unlike conventional relational databases, DynamoDB does not natively support a date and time data type. It can be useful instead to store data and time data as a number data type, using Unix epoch time.
In Amazon DynamoDB, you can use either the DynamoDB API, or PartiQL, a SQL-compatible query language, to add an item to a table. With the DynamoDB API, you use the PutItem operation to add an item to a table. The primary key for this table consists of Artist and SongTitle. You must specify values for these attributes.
DynamoDB supports UTF-8 binary encoded strings which length is limited by the maximum item size which is 400 KB. If String is used as primary key, then the length of it is limited to 2048 bytes for single key and 1024 bytes for composite key.
Each primary key attribute must be a scalar (meaning that it can hold only a single value). The only data types allowed for primary key attributes are string, number, or binary. There are no such restrictions for other, non-key attributes.
you need to add the type information (I assume String here)
aws dynamodb put-item --table-name my_table --item '{ "id": {"S": "1" } }'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With