LoginSignup
3
0

More than 3 years have passed since last update.

DynamoDB の get-item と delete-item

Last updated at Posted at 2019-05-21

こちらで作成したテーブルに対しての操作の話です。
DynamoDB に boto3 で接続 (ハッシュキー、レンジキーを使う)

get-item で次のようなエラーが出ました。

$ aws dynamodb get-item --table-name tbl_iot --endpoint-url http://localhost:8000 --key '{ "id_device": {"S": "ras003" }  }'

An error occurred (ValidationException) when calling the GetItem operation: The number of conditions on the keys is invalid

delete-item でも次のようなエラーが出ます。

$ aws dynamodb delete-item --table-name tbl_iot --endpoint-url http://localhost:8000 --key '{"id_device": {"S": "ras0003"}}'

An error occurred (ValidationException) when calling the DeleteItem operation: The number of conditions on the keys is invalid

ハッシュキー、レンジキーを使っているテーブルに対して、get-item, delete-item で ハッシュキー と レンジキーを 指定しなかったので発生したエラーです。

次のスクリプトならば、エラーは出ません。

go_get.sh
ARGS="--table-name tbl_iot --endpoint-url http://localhost:8000"
#
aws dynamodb get-item $ARGS \
    --key '{"id_device": {"S": "ras0003"},"timestamp": { "S": "20180122082100" }}'
go_delete.sh
ARGS="--table-name tbl_iot --endpoint-url http://localhost:8000"
#
aws dynamodb delete-item $ARGS \
     --key '{"id_device": {"S": "ras0003"},"timestamp": { "S": "20180122082200" }}'
3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0