I'm trying to delete a large number of items in a DynamoDB table using boto and python. My Table is set up with the primary key as a device ID (think MAC address.) There are multiple entries in the table for each device ID, as the secondary key is a UNIX timestamp.
From my reading this code should work:
from boto.dynamodb2.table import Table
def delete_batch(self, guid):
table = Table('Integers')
with table.batch_write() as batch:
batch.delete_item(Id=guid)
Source: http://docs.pythonboto.org/en/latest/dynamodb2_tut.html#batch-writing
However it returns 'The provided key element does not match the schema' as the error message.
I suspect the problem is because guid is not unique in my table.
Given that, is there way to delete multiple items with the same primary key without specifying the secondary key?
You are providing only the hash part of the key and not an item (hash+range) - this is why you get an error and can't delete items.
You can't ask DynamoDB to delete all items with a hash key (the same way Query gets them all)
Read this answer by Steffen for more information
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With