2020年5月8日金曜日

dynamodbの使い方(C++)

aws-doc-sdk-examplesをコンパイルして、サンプルで使い方を学びました。(ubuntu20.04 WSL上でコンパイル)

コマンドは、delete_table,create_table,put_item,get_item,update_itemになります。注意すべきは、put_itemです。全てのattributeが置き換えられます。部分的なattributeに対する更新は、update_itemを使う、ということが分かりました。

tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ls
CMakeCache.txt  batch_get_item       create_table_composite_key  describe_table  put_item
CMakeFiles      cmake_install.cmake  delete_item                 get_item        update_item
Makefile        create_table         delete_table                list_tables     update_table

tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ./list_tables
Your DynamoDB Tables:
HelloTable
mywebsocket_connections
simple-websockets-app-py-connections

tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ./delete_table HelloTable
Table "HelloTable deleted!
tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ./list_tables

Your DynamoDB Tables:
mywebsocket_connections
simple-websockets-app-py-connections

tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ./create_table HelloTable us-east-1
Creating table HelloTable with a simple primary key: "Name"
Table "HelloTable created!

tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ./list_tables
Your DynamoDB Tables:
HelloTable
mywebsocket_connections
simple-websockets-app-py-connections

tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ./put_item HelloTable sugawara Height=172 Weight=85
Done!
tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ./get_item HelloTable sugawara
Height: 172
Name: sugawara
Weight: 85
tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ./put_item HelloTable sugawara Height=172
Done!
tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ./get_item HelloTable sugawara
Height: 172
Name: sugawara

tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ./put_item HelloTable sugawara Height=172 Weight=85
Done!
tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ./get_item HelloTable sugawara
Height: 172
Name: sugawara
Weight: 85
tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ./update_item HelloTable sugawara Height=173
Item was updated
tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$ ./get_item HelloTable sugawara
Height: 173
Name: sugawara
Weight: 85
tak@win10-64:~/aws-doc-sdk-examples/cpp/example_code/dynamodb/build$

0 件のコメント:

コメントを投稿