Saturday 15 January 2011

amazon web services - Increment counter in AWS DynamoDb using boto.dynamodb2 in Python -


I am using the dynamo DBV2 interface for boto to create counter inkram in my table. (I need a V2 interface because I'll work with the index later)

Either way I am not able to do this without getting the item; It is being updated again. Import boto.dynamodb2.table from />

  to boto.dynamodb2.items Import items my_table = table ('My-table') # of existing records Update counter data for {{'key': 'my_key', 'range_key': 'my_range',} item = items (my_table, data) #### 1 item.save ()   < P> What should I do to increase a 'counter' field ??  

See this answer:

This Dynamo DD v1 is working, And I have not tested if it still works with v2

If you are already getting the current value, then it appears

  item.add_attribute ('counter', 1) item.save ()   

will make an update_item request.

You can also straighten an update_item request:

  dynoConnLayer1.update_item ("my_table", {"key": {"S": "my_key"}, '' '' '' "" "" "" "" "" "" "" "" "" "" / Pre>  

No comments:

Post a Comment