简体   繁体   中英

python boto3 dynamodb query function dynamic arguments

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.

尝试使用 ** 正确设置参数:

res = client.query(**params)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM