{"id":2136,"date":"2015-11-30T00:00:52","date_gmt":"2015-11-29T15:00:52","guid":{"rendered":"http:\/\/www.magtranetwork.com\/?p=2136"},"modified":"2015-11-30T17:19:54","modified_gmt":"2015-11-30T08:19:54","slug":"aws_amazon_dynamodb_python_boto3_query_example","status":"publish","type":"post","link":"https:\/\/www.magtranetwork.com\/aws\/aws_amazon_dynamodb_python_boto3_query_example.html","title":{"rendered":"AWS Amazon DynamoDB \u306epython boto3\u306b\u3088\u308bquery\u306e\u66f8\u304d\u65b9\u30fb\u8a18\u8ff0\u30fb\u5b9f\u884c\u65b9\u6cd5\u306e\u4f8b\u30fb\u30b5\u30f3\u30d7\u30eb\u30fbExample\u306b\u3064\u3044\u3066"},"content":{"rendered":"

DynamoDB\u306b\u304a\u3044\u3066query\u306e\u64cd\u4f5c\u306f\u300cDynamoDB\u306e\u30ad\u30fc\u30fb\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u95a2\u3059\u308b\u307e\u3068\u3081 \u301c\u30cf\u30c3\u30b7\u30e5\u30ad\u30fc(\u30d1\u30fc\u30c6\u30a3\u30b7\u30e7\u30f3\u30ad\u30fc)\u3001\u30ec\u30f3\u30b8\u30ad\u30fc(\u30bd\u30fc\u30c8\u30ad\u30fc)\u3001\u30d7\u30e9\u30a4\u30de\u30ea\u30ad\u30fc\u3001\u30ed\u30fc\u30ab\u30eb\u30bb\u30ab\u30f3\u30c0\u30ea\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u30bb\u30ab\u30f3\u30c0\u30ea\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u8aac\u660e\u3001\u9055\u3044\u3001\u4f7f\u3044\u65b9\u3001\u4f7f\u7528\u65b9\u6cd5\u3001\u4f8b\u984c\u3001\u30b5\u30f3\u30d7\u30eb\u301c<\/a>\u300d\u3067\u8aac\u660e\u3057\u305f\u30d7\u30e9\u30a4\u30de\u30ea\u30ad\u30fc\u307e\u305f\u306f\u30bb\u30ab\u30f3\u30c0\u30ea\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u5bfe\u3057\u3066\u691c\u7d22\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n

\u4eca\u56de\u306f\u305d\u306equery\u691c\u7d22\u306b\u3064\u3044\u3066\u7c21\u5358\u306a\u4f8b\u3092\u5099\u5fd8\u9332\u3068\u3057\u3066\u8a18\u8f09\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n

AWS Amazon DynamoDB \u306epython boto3\u306b\u3088\u308bquery\u306e\u66f8\u304d\u65b9\u30fb\u8a18\u8ff0\u30fb\u5b9f\u884c\u65b9\u6cd5\u306e\u4f8b\u30fb\u30b5\u30f3\u30d7\u30eb\u30fbExample\u306b\u3064\u3044\u3066<\/h2>\n

\u30cf\u30c3\u30b7\u30e5\u30ad\u30fc(\u30d1\u30fc\u30c6\u30a3\u30b7\u30e7\u30f3\u30ad\u30fc)\u306e\u307f\u306e\u5834\u5408<\/h3>\n

\u307e\u305a\u3001ExpressionAttributeNames\u3067\u30cf\u30c3\u30b7\u30e5\u30ad\u30fc(\u30d1\u30fc\u30c6\u30a3\u30b7\u30e7\u30f3\u30ad\u30fc)\u306e\u9805\u76ee\u540d\u300chash_key\u300d\u3092KeyConditionExpression\u5185\u3067\u4f7f\u7528\u3059\u308b\u300c#name0\u300d\u306e\u5909\u6570\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n

\u6b21\u306bExpressionAttributeValues\u3067\u30af\u30a8\u30ea\u3067\u691c\u7d22\u3059\u308b\u5024\u300chash_value\u300d\u3092KeyConditionExpression\u5185\u3067\u4f7f\u7528\u3059\u308b\u300c:value0\u300d\u306e\u5909\u6570\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n

KeyConditionExpression\u3067\u4e0a\u8a18\u3067\u8a2d\u5b9a\u3057\u305f\u5909\u6570\u3092\u7528\u3044\u3066\u300c#name0 = :value0\u300d\u306e\u3088\u3046\u306b\u8ad6\u7406\u5f0f\u3092\u66f8\u304d\u307e\u3059\u3002<\/p>\n

\r\nimport boto3\r\n\r\ndynamodb_client = boto3.client('dynamodb', region_name='ap-northeast-1')\r\nhash_value = "HashValue"\r\n\r\nresponse = dynamodb_client.query(\r\n    TableName='DynamoDBTable',\r\n    ExpressionAttributeNames={\r\n        '#name0': 'hash_key'\r\n     },\r\n    ExpressionAttributeValues={\r\n        ':value0': {'S': hash_value}\r\n     },\r\n    KeyConditionExpression='#name0 = :value0'\r\n)\r\n<\/pre>\n

\u30cf\u30c3\u30b7\u30e5\u30ad\u30fc(\u30d1\u30fc\u30c6\u30a3\u30b7\u30e7\u30f3\u30ad\u30fc)\u3068\u30ec\u30f3\u30b8\u30ad\u30fc(\u30bd\u30fc\u30c8\u30ad\u30fc)\u306e\u5834\u5408<\/h3>\n

\u307e\u305a\u3001ExpressionAttributeNames\u3067\u30cf\u30c3\u30b7\u30e5\u30ad\u30fc(\u30d1\u30fc\u30c6\u30a3\u30b7\u30e7\u30f3\u30ad\u30fc)\u306e\u9805\u76ee\u540d\u300chash_key\u300d\u3092KeyConditionExpression\u5185\u3067\u4f7f\u7528\u3059\u308b\u300c#name0\u300d\u306e\u5909\u6570\u306b\u3001
\n\u30ec\u30f3\u30b8\u30ad\u30fc(\u30bd\u30fc\u30c8\u30ad\u30fc)\u306e\u9805\u76ee\u540d\u300crange_key\u300d\u3092KeyConditionExpression\u5185\u3067\u4f7f\u7528\u3059\u308b\u300c#name1\u300d\u306e\u5909\u6570\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n

\u6b21\u306bExpressionAttributeValues\u3067\u30af\u30a8\u30ea\u3067\u691c\u7d22\u3059\u308b\u5024\u300chash_value\u300d\u3092KeyConditionExpression\u5185\u3067\u4f7f\u7528\u3059\u308b\u300c:value0\u300d\u306e\u5909\u6570\u306b\u3001
\n\u30af\u30a8\u30ea\u3067\u691c\u7d22\u3059\u308b\u5024\u300crange_value\u300d\u3092KeyConditionExpression\u5185\u3067\u4f7f\u7528\u3059\u308b\u300c:value1\u300d\u306e\u5909\u6570\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n

KeyConditionExpression\u3067\u4e0a\u8a18\u3067\u8a2d\u5b9a\u3057\u305f\u5909\u6570\u3092\u7528\u3044\u3066\u300c#name0 = :value0 AND #name1 = :value1\u300d\u306e\u3088\u3046\u306b\u8ad6\u7406\u5f0f\u3092\u66f8\u304d\u307e\u3059\u3002<\/p>\n

\r\nimport boto3\r\n\r\ndynamodb_client = boto3.client('dynamodb', region_name='ap-northeast-1')\r\nhash_value = "HashValue"\r\nrange_value = "1448809200"\r\n\r\nresponse = dynamodb_client.query(\r\n    TableName='DynamoDBTable',\r\n    ExpressionAttributeNames={\r\n        '#name0': 'hash_key',\r\n        '#name1': 'range_key'\r\n    },\r\n    ExpressionAttributeValues={\r\n        ':value0': {'S': hash_value},\r\n        ':value1': {'N': range_value}\r\n    },\r\n    KeyConditionExpression='#name0 = :value0 AND #name1 = :value1'\r\n)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

DynamoDB\u306b\u304a\u3044\u3066query\u306e\u64cd\u4f5c\u306f\u300cDynamoDB\u306e\u30ad\u30fc\u30fb\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u95a2\u3059\u308b\u307e\u3068\u3081 \u301c\u30cf\u30c3\u30b7\u30e5\u30ad\u30fc(\u30d1\u30fc\u30c6\u30a3\u30b7\u30e7\u30f3\u30ad\u30fc)\u3001\u30ec\u30f3\u30b8\u30ad\u30fc(\u30bd\u30fc\u30c8\u30ad\u30fc)\u3001\u30d7\u30e9\u30a4\u30de\u30ea\u30ad\u30fc\u3001\u30ed\u30fc\u30ab\u30eb\u30bb\u30ab\u30f3\u30c0\u30ea\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u30bb […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[3,21],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/2136"}],"collection":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/comments?post=2136"}],"version-history":[{"count":1,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/2136\/revisions"}],"predecessor-version":[{"id":2138,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/2136\/revisions\/2138"}],"wp:attachment":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/media?parent=2136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/categories?post=2136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/tags?post=2136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}