{"id":1107,"date":"2019-04-08T19:01:05","date_gmt":"2019-04-08T10:01:05","guid":{"rendered":"http:\/\/idealive.jp\/blog\/?p=1107"},"modified":"2019-04-04T22:19:57","modified_gmt":"2019-04-04T13:19:57","slug":"aws-dynamodb-%e5%88%b6%e9%99%90%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/idealive.jp\/blog\/2019\/04\/08\/aws-dynamodb-%e5%88%b6%e9%99%90%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6\/","title":{"rendered":"AWS DynamoDB \u5236\u9650\u306b\u3064\u3044\u3066"},"content":{"rendered":"<p>\u3053\u3093\u3070\u3093\u306f\u3002\u5148\u65e5DynamoDB\u3092\u4f7f\u7528\u3057\u3066\u3044\u3066\u5236\u9650\u306b\u3072\u3063\u304b\u308a\u307e\u3057\u305f\u306e\u3067\u3001\u5099\u5fd8\u9332\u3068\u3057\u3066\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>\u516c\u5f0f\u30da\u30fc\u30b8\u00a0DynamoDB \u3067\u306e\u5236\u9650<\/p>\n<p><a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/amazondynamodb\/latest\/developerguide\/Limits.html\">https:\/\/docs.aws.amazon.com\/ja_jp\/amazondynamodb\/latest\/developerguide\/Limits.html<\/a><\/p>\n<p>\u53c2\u8003\u306b\u3057\u305fURL\uff1a<\/p>\n<p><a href=\"https:\/\/inokara.hateblo.jp\/entry\/2017\/12\/01\/091105\">https:\/\/inokara.hateblo.jp\/entry\/2017\/12\/01\/091105<\/a><\/p>\n<p>&nbsp;<\/p>\n<h6>\u4e8b\u8c61<\/h6>\n<p>DynamoDB\u306e\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3066CSV\u3092\u8fd4\u3059\u3068\u3044\u3063\u305f\u51e6\u7406\u3067\u3057\u305f\u3002<\/p>\n<p>AWS\u30b3\u30f3\u30bd\u30fc\u30eb\u304b\u3089\u30c7\u30fc\u30bf\u3092\u78ba\u8a8d\u3059\u308b\u3068\u8a72\u5f53\u30c7\u30fc\u30bf\u306f1600\u4ef6\u3042\u308b\u304c\u3001\u5b9f\u969bLambda\u95a2\u6570\u304b\u3089\u53d6\u5f97\u3057\u3066\u307f\u308b\u3068900\u4ef6\u7a0b\u5ea6\u3057\u304b\u53d6\u5f97\u3067\u304d\u306a\u3044\u3002<\/p>\n<p>\u305d\u3046\u3044\u3084\u3001DynamoDB\u3063\u3066\u5236\u9650\u3042\u3063\u305f\u3088\u306d\u3068\u601d\u3044\u51fa\u3057\u3001\u4e0a\u306eURL\u3092\u53c2\u8003\u306b\u3057\u3066Lambda\u95a2\u6570\u3092\u4fee\u6b63\u3059\u308b\u30681600\u4ef6\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3081\u3067\u305f\u3057\u3001\u3081\u3067\u305f\u3057\u3002\u3067\u7d42\u308f\u3063\u3066\u3057\u307e\u3046\u3068\u3042\u308c\u306a\u306e\u3067\u5b9f\u969b\u306b\u78ba\u304b\u3081\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h6>\u691c\u8a3c<\/h6>\n<p>\u307e\u305a\u306f\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u9023\u756a\u3068\u65e5\u672c\u8a9e\u304c525\u6587\u5b57\u306e\u9805\u76ee\u30922000\u4ef6\u30c6\u30fc\u30d6\u30eb\u306b\u767b\u9332\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"\">import json, os\r\nimport boto3\r\n\r\nTABLE_NAME = \"TESTLIMIT\"\r\nWORD = \"\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\u3055\u3057\u3059\u305b\u305d\u305f\u3061\u3064\u3066\u3068\u306a\u306b\u306c\u306d\u306e\u306f\u3072\u3075\u3078\u307b\u307e\u307f\u3080\u3081\u3082\"\r\n\r\ndef lambda_handler(event, context):\r\n    db = boto3.resource(\"dynamodb\")\r\n    table = db.Table(TABLE_NAME)\r\n\r\n    for i in range(1,2001):\r\n        table.put_item(\r\n            Item = {\r\n                \"ID\":str(i),\r\n                \"WORD\":WORD\r\n            }\r\n        )\r\n    return {\r\n        'statusCode': 200,\r\n        'body': json.dumps('Hello from Lambda!')\r\n    }<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5168\u4ef6\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"\">import json, os\r\nimport boto3\r\n\r\nTABLE_NAME = \"TESTLIMIT\"\r\n\r\ndef lambda_handler(event, context):\r\n    db = boto3.resource(\"dynamodb\")\r\n    table = db.Table(TABLE_NAME)\r\n\r\n    res = table.scan()\r\n    items = res[\"Items\"]\r\n    count = len(items)\r\n\r\n    return {\r\n        'statusCode': 200,\r\n        'body': json.dumps(count)\r\n    }<\/pre>\n<p>\u5b9f\u884c\u3059\u308b\u3068654\u4ef6\u3057\u304b\u53d6\u5f97\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1111\" src=\"https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo00-1024x204.png\" alt=\"\" width=\"1024\" height=\"204\" srcset=\"https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo00-1024x204.png 1024w, https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo00-300x60.png 300w, https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo00-768x153.png 768w, https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo00.png 1691w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>\u30c6\u30fc\u30d6\u30eb\u30b9\u30ad\u30e3\u30f3\u306e\u7d50\u679c\u3092dump\u3055\u305b\u3066\u307f\u308b\u3068<\/p>\n<pre class=\"\">{\r\n\"statusCode\": 200,\r\n\"body\": \"{\\\"Items\\\": [{\\\"ID\\\": \\\"228\\\", \\\"WORD\\\":\r\n\uff08\u7565\uff09\r\n\\\"Count\\\": 654, \\\"ScannedCount\\\": 654, \\\"LastEvaluatedKey\\\": {\\\"ID\\\": \\\"427\\\"}, \\\"ResponseMetadata\\\": {\\\"RequestId\\\": \\\"79V2TJ2UC3L78OK6870CKI1O93VV4KQNSO5AEMVJF66Q9ASUAAJG\\\", \\\"HTTPStatusCode\\\": 200, \\\"HTTPHeaders\\\": {\\\"server\\\": \\\"Server\\\", \\\"date\\\": \\\"Sat, 30 Mar 2019 13:08:36 GMT\\\", \\\"content-type\\\": \\\"application\/x-amz-json-1.0\\\", \\\"content-length\\\": \\\"1053322\\\", \\\"connection\\\": \\\"keep-alive\\\", \\\"x-amzn-requestid\\\": \\\"79V2TJ2UC3L78OK6870CKI1O93VV4KQNSO5AEMVJF66Q9ASUAAJG\\\", \\\"x-amz-crc32\\\": \\\"1952349486\\\"}, \\\"RetryAttempts\\\": 0}}\"\r\n}<\/pre>\n<p>\u3042\u308a\u307e\u3057\u305f\u300cLastEvaluatedKey\u300dID:427\u307e\u3067\u53d6\u5f97\u3067\u304d\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u306d\u3002\uff08\u203bID\u3092\u6587\u5b57\u5217\u306b\u3057\u305f\u306e\u3067\u6570\u5b57\u9806\u306b\u53d6\u5f97\u3067\u304d\u3066\u3044\u308b\u308f\u3051\u3067\u306a\u3044\uff09<\/p>\n<p>&nbsp;<\/p>\n<p>\u30b3\u30fc\u30c9\u3092\u4fee\u6b63\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"\">import json, os\r\nimport boto3\r\n\r\nTABLE_NAME = \"TESTLIMIT\"\r\n\r\n\r\ndef lambda_handler(event, context):\r\n\u00a0 \u00a0 db = boto3.resource(\"dynamodb\")\r\n\u00a0 \u00a0 table = db.Table(TABLE_NAME)\r\n\r\n\u00a0 \u00a0 res = table.scan()\r\n\u00a0 \u00a0 items = res[\"Items\"]\r\n\u00a0 \u00a0 print(len(items))\r\n\u00a0 \u00a0 while \"LastEvaluatedKey\" in res:\r\n\u00a0 \u00a0  \u00a0 res = table.scan(ExclusiveStartKey=res[\"LastEvaluatedKey\"])\r\n\u00a0 \u00a0  \u00a0 items.extend(res[\"Items\"])\r\n\u00a0 \u00a0  \u00a0 print(len(items))\r\n\r\n\u00a0 \u00a0 count = len(items)\r\n\r\n\u00a0 \u00a0 return {\r\n\u00a0 \u00a0  \u00a0 'statusCode': 200,\r\n\u00a0 \u00a0  \u00a0 'body': json.dumps(count)\r\n\u00a0 \u00a0 }<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3061\u3089\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1113\" src=\"https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo01-1024x196.png\" alt=\"\" width=\"1024\" height=\"196\" srcset=\"https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo01-1024x196.png 1024w, https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo01-300x58.png 300w, https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo01-768x147.png 768w, https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo01.png 1679w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>\u30ed\u30b0\u3092\u78ba\u8a8d\u3057\u3066\u307f\u308b\u3068654\u4ef6\u305a\u3064\u53d6\u5f97\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1112\" src=\"https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo02-1024x205.png\" alt=\"\" width=\"1024\" height=\"205\" srcset=\"https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo02-1024x205.png 1024w, https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo02-300x60.png 300w, https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo02-768x153.png 768w, https:\/\/idealive.jp\/blog\/wp-content\/uploads\/2019\/04\/dynamo02.png 1597w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h6>\u304a\u308f\u308a\u306b<\/h6>\n<p>\u672c\u65e5\u306fDynamoDB\u306eScan\u306e1MB\u5236\u9650\u306b\u3064\u3044\u3066\u5b9f\u969b\u306e\u30c7\u30fc\u30bf\u3092\u7528\u3044\u3066\u78ba\u8a8d\u3057\u307e\u3057\u305f\u3002AWS\u306f\u4fbf\u5229\u306a\u306e\u3067\u3059\u304c\u3001\u3053\u3046\u3044\u3063\u305f\u5236\u9650\u304c\u7d50\u69cb\u3042\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002\u5236\u9650\u306b\u306f\u304b\u304b\u3089\u306a\u3044\u3060\u308d\u3046\u3068\u30bf\u30ab\u3092\u304f\u304f\u3089\u305a\u3001\u5236\u9650\u306b\u304b\u304b\u3063\u3066\u5927\u4e08\u592b\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u304f\u3088\u3046\u306b\u5fc3\u304c\u3051\u305f\u3044\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u3070\u3093\u306f\u3002\u5148\u65e5DynamoDB\u3092\u4f7f\u7528\u3057\u3066\u3044\u3066\u5236\u9650\u306b\u3072\u3063\u304b\u308a\u307e\u3057\u305f\u306e\u3067\u3001\u5099\u5fd8\u9332\u3068\u3057\u3066\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002 \u516c\u5f0f\u30da\u30fc\u30b8\u00a0DynamoDB \u3067\u306e\u5236\u9650 https:\/\/docs.aws.amazon.com\/ja_jp\/amazo&#8230;<a class=\"read-more-link button\" href=\"https:\/\/idealive.jp\/blog\/2019\/04\/08\/aws-dynamodb-%e5%88%b6%e9%99%90%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6\/\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":8,"featured_media":1116,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-1107","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aws"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts\/1107"}],"collection":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/comments?post=1107"}],"version-history":[{"count":4,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts\/1107\/revisions"}],"predecessor-version":[{"id":1117,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts\/1107\/revisions\/1117"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/media\/1116"}],"wp:attachment":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/media?parent=1107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/categories?post=1107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/tags?post=1107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}