環境
$ aws --version
aws-cli/1.16.155 Python/2.7.16 Darwin/19.0.0 botocore/1.12.145
テーブル一覧を表示
$ aws dynamodb list-tables
{
"TableNames": [
"Forum",
"Movies"
]
}
テーブル情報を知る
$ aws dynamodb describe-table --table-name Movies
{
"Table": {
"TableArn": "arn:aws:dynamodb:ap-northeast-1:470824059488:table/Movies",
"AttributeDefinitions": [
{
"AttributeName": "title",
"AttributeType": "S"
},
{
"AttributeName": "year",
"AttributeType": "N"
}
],
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"WriteCapacityUnits": 10,
"ReadCapacityUnits": 10
},
"TableSizeBytes": 0,
"TableName": "Movies",
"TableStatus": "ACTIVE",
"TableId": "f487b461-41df-41da-aaed-557a60291da8",
"KeySchema": [
{
"KeyType": "HASH",
"AttributeName": "year"
},
{
"KeyType": "RANGE",
"AttributeName": "title"
}
],
"ItemCount": 0,
"CreationDateTime": 1569596682.931
}
}
データを挿入する
$ aws dynamodb put-item --table-name Movies --item '{"title":{"S":"Titanic"},"year":{"N":"1997"}}'
$ aws dynamodb put-item --table-name Movies --item '{"title":{"S":"The Godfather"},"year":{"N":"1972"}}'
テーブルの全てのデータを表示
$ aws dynamodb scan --table-name=Movies
{
"Count": 2,
"Items": [
{
"year": {
"N": "1997"
},
"title": {
"S": "Titanic"
}
},
{
"year": {
"N": "1972"
},
"title": {
"S": "The Godfather"
}
}
],
"ScannedCount": 2,
"ConsumedCapacity": null
}
参考
aws cli で DynamoDB を使う - Qiita
DynamoDBをlocal環境で動かしてみる - Qiita