I have the following line of code :
table.put_item( Item={'filename' : key, 'status' : {'M' : iocheckdict }})
The iocheckdict
looks like this:
{'A': 'One', 'C': 'Three', 'D': 'Four', 'B': 'Two', 'E': 'Five'}
So, when I am running the code, I get this error:
An error occurred (ValidationException) when calling the PutItem operation: One or more parameter values were invalid: Type mismatch for key status expected: S actual: M
Why am I getting this, even though I mentioned M
as the type of the data?
PS : I have 2 columns filename
and status
in my table
Attribute definitions of the table:
"AttributeDefinitions": [
{
"AttributeName": "filename",
"AttributeType": "S"
},
{
"AttributeName": "status",
"AttributeType": "S"
}
],
I understand that the type of status
is S, but I haven't found the map type while creating the table. All I found are string
, binary
and number
.
Easier way to insert into dynamodb
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table("table_name")
item={}
item['filename'] = key
item['status'] = {'A': 'One', 'C': 'Three', 'D': 'Four', 'B': 'Two', 'E': 'Five'}
table.put_item(Item=item)
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