{Alibaba Table Store} Start the Tablestore CLI and configure access information

https://www.alibabacloud.com/help/en/tablestore/developer-reference/tablestore-cli

https://qiita.com/rakital/items/5dc1309c192f111df35f
https://www.softbank.jp/biz/blog/cloud-technology/articles/202302/alibaba-tablestore-restfulapi/

 

-- 1. tablestore-cliのセットアップ

unzip aliyun-tablestore-cli-darwin-amd64-2023-10-08-8612e96.zip

./ts

help


config \
--id 111111111111111111111111 \
--key 111111111111111111111111111111

 

-- 2. Activate Tablestore


enable_service

 

-- 3. Create an instance

ap-northeast-1では下記エラー
Message: code: 404, Primary cluster does not exist

The name of an instance must be unique within a region.


create_instance \
-d instance123 \
-n instance123 \
-r cn-hangzhou

 

list_instance \
-r cn-hangzhou


describe_instance \
-n instance123 \
-r cn-hangzhou


config \
--endpoint http://instance123.cn-hangzhou.ots.aliyuncs.com \
--instance instance123

 

-- 4. Create a table

create \
--table tab1 \
--pk '[{"c":"uid","t":"string"}, {"c":"pid","t":"integer"}]' \
--ttl 86400  \
--version 1 


list -a

use --wc -t tab1

desc

 

-- 5. Insert data

put --pk '["86", 6771]' --attr '[{"c":"name", "v":"hoge1"}, {"c":"country", "v":"fuga1"}]'
put --pk '["86", 6772]' --attr '[{"c":"name", "v":"hoge2"}, {"c":"country", "v":"fuga2"}]'
put --pk '["86", 6773]' --attr '[{"c":"name", "v":"hoge3"}, {"c":"country", "v":"fuga3"}]'

-- 6. Read data

get --pk '["86",6771]'

-- 7. Scan data

scan --limit 10

-- 8. Update data

update --pk '["86", 6771]' --attr '[{"c":"name", "v":"aaa"}, {"c":"country", "v":"bbb"}]'  --condition ignore

scan --limit 10

 


-- 9. Delete data


delete --pk '["86", 6771]'
scan --limit 10

 

-- 10. Delete a table

drop -t tab1 -y
list -a

 


-- 11. クリーンアップ

インスタンスの削除はtablestore-cliで、できない模様


aliyun ots ListInstance \
--endpoint ots.cn-hangzhou.aliyuncs.com

 

aliyun ots DeleteInstance \
--endpoint ots.cn-hangzhou.aliyuncs.com \
--InstanceName instance123