简体   繁体   English

Boto3 DynamoDB 查询条件不起作用(eq 除外)

[英]Boto3 DynamoDB Query Conditions not working (except for eq)

I am using boto3 to create a simple DynamoDB query as follows:我正在使用 boto3 创建一个简单的 DynamoDB 查询,如下所示:

response = table.query(
    KeyConditionExpression=Key('course-lesson-id-part').eq(1)
)

This query works and return the single item just like it should.此查询有效并按应有的方式返回单个项目。

course-lesson-id-part is my primary partition key and is numeric; course-lesson-id-part 是我的主分区键,是数字; I have two items in my table:我的表中有两个项目:

course-lesson-id-part: 1
course-lesson-id-part: 2

Ideally, and according to this reference , I should be able to use the following to query all items with course-lesson-id-part > 0:理想情况下, 根据此参考资料,我应该能够使用以下内容查询 course-lesson-id-part > 0 的所有项目:

response = table.query(
    KeyConditionExpression=Key('course-lesson-id-part').gt(0)
)

None of the other DB Query conditions seem to be working other than.eq, which does me no good here.除了 .eq 之外,其他数据库查询条件似乎都不起作用,这对我没有好处。

Anyone have any ideas?谁有想法?

Only eq is supported for partition keys.分区键仅支持eq

You must specify the partition key name and value as an equality condition.您必须将分区键名称和值指定为相等条件。

Source: Working with Queries资料来源: 使用查询

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM