DynamoDB BatchWriteItem

1,535 views
Skip to first unread message

alanp

unread,
Apr 20, 2012, 5:15:58 AM4/20/12
to boto-users
Hi Mitch
When will we see it in Boto?
Thanks
Alan

Mitchell Garnaat

unread,
Apr 20, 2012, 1:03:57 PM4/20/12
to boto-...@googlegroups.com
Just committed an initial version.  Let me know what you think or if you need more info to get started with it.

Mitch


--
You received this message because you are subscribed to the Google Groups "boto-users" group.
To post to this group, send email to boto-...@googlegroups.com.
To unsubscribe from this group, send email to boto-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/boto-users?hl=en.


Alan Pound

unread,
Apr 20, 2012, 1:52:14 PM4/20/12
to boto-...@googlegroups.com
Thanks Mitch - I'll have a look at it on Monday.
Alan
winmail.dat

egottschalk

unread,
Apr 23, 2012, 5:30:27 PM4/23/12
to boto-...@googlegroups.com
Hi Mitch,

I noticed that BatchWriteItem will throw an exception with duplicate keys:

item1 = table.new_item("a", { "message" : "message for key a" })
item2 = table.new_item("a", { "message" : "new message for key a" })

batch_list = c.new_batch_write_list()
batch_list.add_batch(table, puts=[item1, item2])
response = batch_list.submit()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.6/site-packages/boto-2.3.0-py2.6.egg/boto/dynamodb/batch.py", line 194, in submit
    return self.layer2.batch_write_item(self)
  File "/Library/Python/2.6/site-packages/boto-2.3.0-py2.6.egg/boto/dynamodb/layer2.py", line 439, in batch_write_item
    object_hook=item_object_hook)
  File "/Library/Python/2.6/site-packages/boto-2.3.0-py2.6.egg/boto/dynamodb/layer1.py", line 330, in batch_write_item
    object_hook=object_hook)
  File "/Library/Python/2.6/site-packages/boto-2.3.0-py2.6.egg/boto/dynamodb/layer1.py", line 133, in make_request
    retry_handler=self._retry_handler)
  File "/Library/Python/2.6/site-packages/boto-2.3.0-py2.6.egg/boto/connection.py", line 746, in _mexe
    status = retry_handler(response, i, next_sleep)
  File "/Library/Python/2.6/site-packages/boto-2.3.0-py2.6.egg/boto/dynamodb/layer1.py", line 165, in _retry_handler
    data)
boto.exception.DynamoDBResponseError: DynamoDBResponseError: 400 Bad Request
{u'message': u'Provided list of item keys contains duplicates', u'__type': u'com.amazon.coral.validate#ValidationException'}

The single writes meanwhile work fine:

item1.put()
item2.put()

Is this expected behavior?

Thanks,
Eric

Mitchell Garnaat

unread,
Apr 23, 2012, 9:08:07 PM4/23/12
to boto-...@googlegroups.com
Hi -

The error is coming directly from DynamoDB so I think that's a restriction of the BatchWriteItem request.  I could probably check that on the client-side although I generally tend to let those type of errors come directly from the service.

Mitch

--
You received this message because you are subscribed to the Google Groups "boto-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/boto-users/-/JhRg5oEI0GMJ.
Reply all
Reply to author
Forward
0 new messages