python - Search in Dynamodb db
问题描述
I'm using Lambda, API-gateway & Dynamodb using python 3.6 I have a dynamodb table for order id:
- orderId (primary Key|String)
- orderStatus (String)
- orderCode (String)
- date (String)
OrderId is unique. Whenever I try to query by date I get the following error:
{
"errorMessage": "An error occurred (ValidationException) when calling the GetItem operation: The provided key element does not match the schema",
"errorType": "ClientError",
"stackTrace": [
[
"/var/task/lambda_function.py",
8,
"lambda_handler",
"\"date\":day"
]
My code:
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Shops')
def lambda_handler(event, context):
day = event['day']
resp = table.get_item(Key={
"date":day
})
return resp['Item']
I want to write a query that takes one date as input and will return all orders on that day:
This was my input:
{
"day": "191215"
}
解决方案
推荐阅读
- assembly - 汇编 x86 无限循环问题 MOV CX, 12 后程序 RET
- r - R情绪分析;找不到“词典”;“感情”受损?
- c++ - C++ 成员变量用非零值初始化,但在成员函数中为零
- typescript - 基于 Typescript 中的对象数组创建对象类型
- c++ - C++ 将父指针降级为用作函数参数的子指针
- python - 无论如何要撤消按位或?
- machine-learning - 在类似 OAR2 的集群中运行多个 Keras 模型
- azure - 自定义 Azure B2C 注册页面
- r - 是否有 R 命令使 Keras Tensorflow-GPU 在 CPU 上运行?
- php - 如何实现 id 的递增连接值