#author("2018-09-20T15:50:34+00:00","","") [[AWSメモ]] > * DynamoDBでAttributesToGetを指定した場合のキャパシティユニット [#t53c56b8] #setlinebreak(on); #contents ** [#a907b786] #html(<div style="padding-left:10px">) #mycode2(){{ import boto3 from boto3.dynamodb.conditions import Attr import json dynamodb = boto3.resource('dynamodb') table = dynamodb.Table('SampleTable') def create_test_data(): base_text = '1234567890' text_data = '' for i in range(100): text_data = text_data + base_text for i in range(1): for j in range(10): res = table.put_item( Item = { "pkey": f'pkey-{i+1:05d}', "skey": f'skey-{j+1:05d}', "column001": text_data, "column002": text_data, "column003": text_data, "column004": text_data, "column005": text_data, "column006": text_data, "column007": text_data, "column008": text_data, "column009": text_data, "column010": text_data }, ReturnConsumedCapacity = 'INDEXES' ) print(res) def get_item(pkey, skey, column): args = {} args['Key'] = {'pkey': pkey, 'skey': skey} args['ProjectionExpression'] = column args['ReturnConsumedCapacity'] = 'INDEXES' res = table.get_item(**args) print(json.dumps(res['ConsumedCapacity'], indent=4)) def main(): #create_test_data() print('### column * 5 ###') get_item('pkey-00001', 'skey-00001', 'column001, column002 ,column003, column004, column005') print('### column * 10 ###') get_item('pkey-00001', 'skey-00001', 'column001, column002 ,column003, column004, column005, column006, column007 ,column008, column009, column010') if __name__ == '__main__': main() }} #html(</div>)