【问题标题】:AWS DynamoDB CLI command not workingAWS DynamoDB CLI 命令不起作用
【发布时间】:2016-10-16 12:19:01
【问题描述】:

我无法通过命令行执行 put-item 命令 - 示例如下。

C:\Users\Ishtiaque>aws dynamodb put-item --table-name weatherstationdata --item '{"stationid":{"S":"000001"},"dateandtime" : {"S": "2015/12/25 00:00"},"temperature": {"N" : "0"}}' --profile LOAdmin


Unknown options: {S:, 2015/12/25 00:00},temperature:, {N, :, 0}}', :

我也尝试过“\”开关,例如:

C:\Users\Ishtiaque>aws dynamodb put-item --table-name weatherstationdata --item '{\"\stationid":{\"\S":\"\000001"},"dateandtime" : {\"\S": \"\2015/12/25 00:00"},\"\temperature": {\"\N" : \"\0"}}' --profile LOAdmin

但还是失败了。

我认为这与“”符号有关,但不确定如何解决。

我可以从控制台创建项目,当使用“get-item”命令时,我遇到了类似的错误。

【问题讨论】:

    标签: amazon-web-services command-line-interface


    【解决方案1】:

    您的表达式看起来不错,但如果您有复杂的 JSon,您可以创建一个新的 JSon 文件 file.json

    {
        "dateandtime": {
            "S": "2015/12/25 00:00"
        },
        "stationid": {
            "S": "000001"
        },
        "temperature": {
            "N": "0"
        }
    }
    

    然后将其作为表达式传递给您的命令

    aws dynamodb put-item --table-name weatherstationdata \
        --item file://item.json --profile LOAdmin
    

    您应该确保在 Json 中的键之后不要包含空格,这样这样的东西可以在 CLI 中工作

    aws dynamodb put-item --table-name weatherstationdata --item '{"stationid": {"S": "000001"},"dateandtime": {"S": "2015/12/25 00:00"},"temperature": {"N": "0"}}' --profile LOAdmin
    

    【讨论】:

    • 好的,请确保accept the answer 如果您不在密钥后面添加空格,它应该可以工作
    猜你喜欢
    • 2015-12-24
    • 2020-10-01
    • 1970-01-01
    • 2021-04-28
    • 2020-11-11
    • 2018-07-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多