【问题标题】:Query key condition not supported, python不支持查询关键条件,python
【发布时间】:2021-08-13 09:47:02
【问题描述】:
response = tblEth_orders.query(
    IndexName = 'date-index',
    KeyConditionExpression= '#temp >= :myDate',
    ExpressionAttributeValues= {   
        ':myDate': week_ago_t
    },
    ExpressionAttributeNames= {
        "#temp": "date"
    }
   )

response = response['Items']
print(response)

botocore.exceptions.ClientError:调用查询操作时发生错误(ValidationException):不支持查询键条件

请告诉我解决此错误的另一种方法。

【问题讨论】:

  • 请提供有关表和索引的更多详细信息
  • [ {'AttributeName': 'date', 'AttributeType': 'S'}, {'AttributeName': 'listing_id', 'AttributeType': 'S'}, {'AttributeName': 'order_id', 'AttributeType': 'S'}, {'AttributeName': 'username', 'AttributeType': 'S'} ] 关于表

标签: python amazon-dynamodb boto3


【解决方案1】:

发生这种情况是因为密钥条件不正确。

  • 如果您的索引('date-index')只有一个分区键,那么您只能在键条件表达式中使用 '=' 运算符。你只能获取。

  • 如果您的索引('date-index')有一个分区键和一个排序键,那么您可以在分区键的键条件表达式中使用“=”运算符,并为排序键使用几乎任何标准的比较运算符。 '' 等运算符。

有关可用运算符的文档,请参见此处: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-20
    • 2017-04-01
    相关资源
    最近更新 更多