Mister_L
Mister_L

Reputation: 2611

boto - delete fails because of schema mismatch

I have a table called Events, with deviceID as a primary key, and timeStamp as a sort key. Now I'm trying to delete an item given both of these keys:

dynamodb = boto3.resource('dynamodb')
events_table = dynamodb.Table('Events')

events_table.delete_item(
    Key = {
       'deviceID'  : 'xyz123',
       'timeStamp' : 12314156.54345
    }
)

Why am I getting a schema mismatch error? Output below:

File "C:\Python27\lib\site-packages\boto3\resources\factory.py", line 498,  in do_action
 response = action(self, *args, **kwargs)
File "C:\Python27\lib\site-packages\boto3\resources\action.py", line 83, in __call__
response = getattr(parent.meta.client, operation_name)(**params)
File "C:\Python27\lib\site-packages\botocore\client.py", line 236, in _api_call
return self._make_api_call(operation_name, kwargs)
File "C:\Python27\lib\site-packages\botocore\client.py", line 500, in _make_api_call
raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the DeleteItem operation: 
The provided key element does not match the schema

Upvotes: 1

Views: 1356

Answers (1)

Eyal Ch
Eyal Ch

Reputation: 10056

according to documentation:

client = boto3.client('dynamodb')

client.delete_item(TableName='tbl_name',
  Key={
       'deviceID':{'S':'xyz123'},
       'timeStamp' : '12314156.54345'
  })

Upvotes: 1

Related Questions