boto - 由于架构不匹配而导致删除失败

时间:2016-04-14 17:03:32

标签: amazon-dynamodb boto boto3

我有一个名为Events的表,其中deviceID作为主键,timeStamp作为排序键。现在我试图删除给出这两个键的项目:

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

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

为什么我收到架构不匹配错误?输出如下:

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

1 个答案:

答案 0 :(得分:1)

根据documentation

client = boto3.client('dynamodb')

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