python - python boto3 dynamodb 查询函数动态参数
问题描述
Python boto3 库 dynamodb.query 方法。我们如何传递动态参数
client = boto3.resource("dynamodb")
params = {
"Limit": 10,
"ExpressionAttributeNames":{"#pk":"pk"},
"ExpressionAttributeValues":{":pk":"value"},
"KeyConditionExpression":"#pk=:pk",
"ScanIndexForward": False
}
res = client.query(params)
它以错误响应:
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)
推荐阅读
- python - 试图建立
- vim - Vim 选项作用域:global-local、local 和 global
- php - 如何将 30 分钟添加到当前时间戳?
- javascript - Bootstrap 4下拉菜单悬停与Jquery
- c - getchar() 在 while 循环中用作条件时如何工作
- java - JBoss 到 Spring Boot 和 Spring Security 升级:X509 身份验证问题
- python - 从 CSV 文件写入 CSV 文件
- android - 如何解决 RecyclerView 和 OnClickAdapter 的问题?
- graph - 具有互斥边的二部图中的完美匹配
- hana - 如果满足条件,Hana 是否只能允许用户查看视图的特定行