{"id":8944,"date":"2016-11-28T16:06:16","date_gmt":"2016-11-28T07:06:16","guid":{"rendered":"http:\/\/www.skyarch.net\/blog\/?p=8944"},"modified":"2016-11-30T02:17:44","modified_gmt":"2016-11-29T17:17:44","slug":"boto3%e3%81%a7dynamodb%e3%82%92%e6%93%8d%e4%bd%9c%e3%81%97%e3%81%a6%e3%81%bf%e3%81%be%e3%81%97%e3%81%9f","status":"publish","type":"post","link":"https:\/\/www.skyarch.net\/blog\/boto3%e3%81%a7dynamodb%e3%82%92%e6%93%8d%e4%bd%9c%e3%81%97%e3%81%a6%e3%81%bf%e3%81%be%e3%81%97%e3%81%9f\/","title":{"rendered":"Boto3\u3067DynamoDB\u3092\u64cd\u4f5c\u3057\u3066\u307f\u307e\u3057\u305f"},"content":{"rendered":"<h1>\u6982\u8981<\/h1>\n<p>Python SDK\u306eboto3\u3092\u4f7f\u3063\u3066\u3001DynamoDB\u306e\u64cd\u4f5c\u3092\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<h1>\u30c6\u30fc\u30d6\u30eb\u306e\u4f5c\u6210<\/h1>\n<pre>\n# -*- coding: utf-8 -*-\n\nimport boto3\nfrom boto3.session import Session\n\ndynamodb = boto3.resource('dynamodb')\n\ndef create_table():\n  table = dynamodb.create_table(\n    TableName = 'customer',\n    KeySchema =[\n      {\n        'AttributeName' : 'id',\n        'KeyType' : 'HASH'\n      },\n      {\n        'AttributeName' : 'name',\n        'KeyType' : 'RANGE'\n\n      }\n    ],\n    AttributeDefinitions = [\n      {\n        'AttributeName' : 'id',\n        'AttributeType' : 'S'\n      },\n      {\n        'AttributeName' : 'name',\n        'AttributeType' : 'S'\n      }\n    ],\n\n    ProvisionedThroughput = {\n      'ReadCapacityUnits' : 1,\n      'WriteCapacityUnits' : 1\n    }\n  )\n\n  table.meta.client.get_waiter('table_exists').wait(TableName = 'customer')\n  print (table.item_count)\n\n\ncreate_table()\n<\/pre>\n<p>https:\/\/github.com\/handa3\/study\/blob\/master\/aws\/dynamodb\/create_table.py<\/p>\n<h1>\u30c6\u30fc\u30d6\u30eb\u306e\u524a\u9664<\/h1>\n<pre>\n# -*- coding: utf-8 -*-\n\nfrom __future__ import print_function # Python 2\/3 compatibility\nimport boto3\n\ndynamodb = boto3.resource('dynamodb')\ntable = dynamodb.Table('customer')\n\ntable.delete()\n<\/pre>\n<p>https:\/\/github.com\/handa3\/study\/blob\/master\/aws\/dynamodb\/delete_table.py<\/p>\n<h1>\u3055\u3044\u3054\u306b<\/h1>\n<p>Sdk\u3092\u4f7f\u3044\u3053\u306a\u305b\u3070\u51fa\u6765\u308b\u3053\u3068\u304c\u3069\u3093\u3069\u3093\u5e83\u304c\u3063\u3066\u697d\u3057\u3044\u3067\u3059\uff01<br \/>\nPython\u3082\u597d\u304d\u306a\u306e\u3067\u3069\u3093\u3069\u3093\u81ea\u52d5\u5316\u51fa\u6765\u305f\u3089\u3044\u3044\u306a\u3068\u601d\u3063\u3066\u307e\u3059\u3002<\/p>\n<p>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u672c\u4eba\u306e\u8a31\u53ef\u3092\u5f97\u3066\u3001\u63b2\u8f09\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 Python SDK\u306eboto3\u3092\u4f7f\u3063\u3066\u3001DynamoDB\u306e\u64cd\u4f5c\u3092\u3057\u3066\u307f\u307e\u3057\u305f\u3002 \u30c6\u30fc\u30d6\u30eb\u306e\u4f5c\u6210 # -*- coding: utf-8 -*- import boto3 from boto3.session im&#8230;<\/p>\n","protected":false},"author":1,"featured_media":8964,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"8944","footnotes":""},"categories":[20,19,9],"tags":[183,65],"class_list":{"0":"post-8944","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-aws","8":"category-19","9":"category-dev","10":"tag-boto","11":"tag-python","12":"ja"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/8944","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/comments?post=8944"}],"version-history":[{"count":3,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/8944\/revisions"}],"predecessor-version":[{"id":8947,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/8944\/revisions\/8947"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media\/8964"}],"wp:attachment":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media?parent=8944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/categories?post=8944"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/tags?post=8944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}