Invalid type for AWS DynamoDB put-item via CLI (unicode v. dict)

前端 未结 2 1073
既然无缘
既然无缘 2021-02-07 01:26

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:

{
           


        
相关标签:
2条回答
  • 2021-02-07 02:09

    We cannot provide a plain JSON schema as an input to the dynamodb put-item command. We need to provide the attribute(s) data type along with its value.

    But if you have a complex JSON schema and you are new to the aws dynamodb cli commands then it becomes really tedious for you to prepare your input JSON file.

    But we have an easy solution as well, please follow these steps:

    • Prepare a sample JSON schema which you want to insert into your dynamodb table.
    • Login to AWS Console, go to DynamoDB -> Tables -> , and from the top tabs chose Items, it will show you the data if any already.
    • Now click on the Create Item, it will open a new window and from there choose the option Text instead of Tree. Paste your sample JSON schema there and save this item.
    • Now Select that record and from Actions choose the option Export to .csv. This csv file contains your JSON attribute name (keys), their corresponding values along with their data type.
    • Now most of the work has been done for you and you can easily construct the input JSON file for your dynamodb put-item command.
    0 讨论(0)
  • 2021-02-07 02:14

    you need to add the type information (I assume String here)

    aws dynamodb put-item --table-name my_table --item '{ "id": {"S": "1" } }'
    
    0 讨论(0)
提交回复
热议问题