Answer a question

I'm having trouble understanding why below query on a DynamoDB table doesn't work:

dict_table.query(KeyConditionExpression='norm = :cihan', ExpressionAttributeValues={':cihan': {'S': 'cihan'}})

and throws this error:

ClientError: An error occurred (ValidationException) when calling the Query operation: One or more parameter values were invalid: Condition parameter type does not match schema type

while the following works:

dict_table.query(KeyConditionExpression=Key('norm').eq('cihan'))

norm is a field with type string. I'm using boto3 v 1.4.0 and following the docs:

In [43]: boto3.__version__
Out[43]: '1.4.0'

Can anyone see what's the error in the first query?

Bonus question: What's with all the tokens and the need to replace them all the time? Why can't I just say dict_table.query(KeyConditionExpression='norm = cihan')

Answers

Please change the ExpressionAttributeValues as mentioned below.

ExpressionAttributeValues={':cihan': 'cihan'}
Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐