0

Python boto3 library dynamodb.query method. how do we pass dynamic arguments

client = boto3.resource("dynamodb")

params = {
    "Limit": 10,
    "ExpressionAttributeNames":{"#pk":"pk"},
    "ExpressionAttributeValues":{":pk":"value"},
    "KeyConditionExpression":"#pk=:pk",
    "ScanIndexForward": False
}
res = client.query(params)

It responds with error:

An error occurred (ValidationException) when calling the Query operation: Either the KeyConditions or KeyConditionExpression parameter must be specified in the request.

1 Answer 1

2

Try with ** to set the parameters correctly:

res = client.query(**params)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.