Dynamodb client query behaves differently depending on whether it is a new client or it comes from the resource
See original GitHub issueI have a parameters variable
params = {
"TableName": "name_of_table",
"KeyConditionExpression": "user_id = :user_id",
"ExpressionAttributeValues": {
":user_id": { "S": "username" }
},
}
I also created a client
client = boto3.client("dynamodb")
and ran
client.query(**params)
which returns the correct data from our table. But when we create a resource
resource = boto3.resource("dynamodb")
and run
resource.meta.client.query(**params)
I get the error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 661, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.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
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Class: Aws::DynamoDB::Client — AWS SDK for Ruby V2
Creates a new item, or replaces an old item with a new item. #query(options = {}) ⇒ Types::QueryOutput. The Query operation finds items...
Read more >DynamoDB — Boto3 Docs 1.26.34 documentation - AWS
With DynamoDB, you can create database tables that can store and retrieve any amount of data, and serve any level of request traffic....
Read more >6 Common DynamoDB Issues - Dashbird
1. Query Condition Missed Key Schema Element · 2. Resource Not Found Exception · 3. Cannot do Operations on a Non-Existent Table ·...
Read more >Ten Examples of Getting Data from DynamoDB with Python ...
We'll use both a DynamoDB client and a DynamoDB table resource in ... or you can quickly create your new DynamoDB table with...
Read more >Why Your DynamoDB Scan or Query Is Not Returning All Your ...
To determine if your scan or query is running up against the limit, you need to look at the LastEvaluatedKey that is returned...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like client.query requires the attribute values to be in the encoded format, i.e.
":user_id": { "S": "username" }
but the resource.meta.client.query requires it to be uncoded, i.e.":user_id": "username"
EDIT: The documentation leads me to believe that it should be encoded in both casesI think you missed his point. I believe it is fair to expect that
boto3.client('dynamodb')
andboto3.resource('dynamodb').meta.client
should behave the same way and his example demonstrate that it is not the case.