Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
58
Help us understand the problem. What is going on with this article?
@ekzemplaro

aws cli で DynamoDB を使う

More than 1 year has passed since last update.

city という名前のテーブルを作成

aws dynamodb create-table --table-name 'cities' \
--attribute-definitions '[{"AttributeName":"key","AttributeType": "S"}]' \
--key-schema '[{"AttributeName":"key","KeyType": "HASH"}]' \
--provisioned-throughput '{"ReadCapacityUnits": 5,"WriteCapacityUnits": 5}'

データの挿入

#
aws dynamodb put-item --table-name cities --item '{ "population": { "N": "38164" }, "date_mod": { "S": "1950-6-22" }, "key": { "S": "t0924" }, "name": { "S": "足利" } }'
#
aws dynamodb put-item --table-name cities --item '{ "population": { "N": "72391" }, "date_mod": { "S": "1950-8-30" }, "key": { "S": "t0925" }, "name": { "S": "日光" } }'
#
aws dynamodb put-item --table-name cities --item '{ "population": { "N": "56148" }, "date_mod": { "S": "1950-9-7" }, "key": { "S": "t0926" }, "name": { "S": "下野" } }'
#

データのスキャン

aws dynamodb scan --table-name cities

キーを指定してデータの取得

aws dynamodb get-item --table-name cities  --key '{ "key": {"S": "t0926" }  }'

キーを指定してデータの削除

aws dynamodb delete-item --table-name cities  --key '{"key": {"S": "t0924"}}'

テーブルの削除

aws dynamodb delete-table --table-name cities

レコード数のカウント

aws dynamodb scan --table-name cities --select "COUNT"

テーブル名の取得

aws dynamodb list-tables

テーブルに関する情報の取得

aws dynamodb describe-table --table-name cities

ローカルに立てた DynamoDB を取り扱う時

1) テーブル名の取得

aws dynamodb list-tables --endpoint-url http://localhost:8000

2) データのスキャン

aws dynamodb scan --table-name cities --endpoint-url http://localhost:8000
58
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ekzemplaro
Python3,Node.js,Go,Nginx,RaspberryPi あたりがカバー範囲です。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
58
Help us understand the problem. What is going on with this article?