【发布时间】:2019-06-25 07:29:41
【问题描述】:
我想使用 python 使用主键从 Dynamo-Db 表中获取数据。 我的表名是“CustomerDetails”,主键是“Email-id”。 我将从 API Gateway 触发这个 Lambda 函数。
import boto3
from boto3.dynamodb.conditions import Key, Attr
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('CustomerDetails')
def lambda_handler(event, context):
response = table.get_item(key={'Email-id':event})
#response = table.query(KeyConditionExpression=Key('Email-id').eq(event))
以上代码不工作。我在这里做错了什么?
【问题讨论】:
-
删除了我的答案,因为正如 Mark B 所说,我正在查看 dynamodbClient 而不是 dynamodb.Table 话虽如此,您能否提供来自 table.get_item() 调用的响应?
标签: python-3.x amazon-web-services amazon-dynamodb boto3 api-gateway