通过仅指定索引键从具有范围键的DynamoDB表中检索项

2024-06-28 20:59:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个设置了主键和范围键的表:

user_id
timestamp_joined

使用boto api层,有没有一种方法可以通过指定用户id(不带范围键)来检索项目?每次在不指定范围键的情况下执行getItem()查询时,都会失败。我只能通过指定范围键(timestamp_joined)使其工作。

仅按用户id提取时的错误消息如下:

boto.exception.DynamoDBResponseError: DynamoDBResponseError: 400 Bad Request 
{'message': 'One or more parameter values were invalid: The provided 
key size does ot match with that of the schema', '__type':
'com.amazon.coral.validate#ValidationException'} 

Tags: 项目方法用户apiid消息错误情况