使用 boto3 dynamodb 客户端的 FilterExpression 语法错误

Hex*_*exy 1 python amazon-web-services amazon-dynamodb boto3

我正在尝试使用 boto3 的低级客户端 api 查询 dynamodb。

   response = client.query(
        TableName='People',
        IndexName='country-index',
        KeyConditionExpression='country = :country',
        FilterExpression="attribute_not_exists('age') AND attribute_not_exists('address')",
        ExpressionAttributeValues={
            ":country":{"S": "USA"}
        },
        Limit=100
    )
Run Code Online (Sandbox Code Playgroud)

我收到一个语法错误:

调用查询操作时发生错误(ValidationException):Invalid FilterExpression: Syntax error; 标记:“'”,附近:“('年龄”

boto3 中的文档重定向到 Amazon 开发人员指南。我找不到 client.query(...) 的语法。此处列出的示例用于使用 table.query(...)

not*_*est 5

请更改FilterExpression如下所述。

FilterExpression="attribute_not_exists(age) AND attribute_not_exists(address)",
Run Code Online (Sandbox Code Playgroud)