[英]AWS Python: can't get data from a dynamodb in a lambda with get_item
I was expecting to get my data.我期待得到我的数据。 Instead I get this:相反,我得到这个:
{'ResponseMetadata': {'RequestId': 'XXXXXXXXXXXXXXXXXXXXX', 'HTTPStatusCode': 200, 'HTTPHeaders': {'server': 'Server', 'date': 'Mon, 28 Feb 2022 01:19:00 GMT', 'content-type': 'application/x-amz-json-1.0', 'content-length': '2', 'connection': 'keep-alive', 'x-amzn-requestid': 'XXXXXXXXXXXXXXXXXX', 'x-amz-crc32': 'XXXXXXXXX'}, 'RetryAttempts': 0}}
I mean, there are useful informations but, where is the data in this response???我的意思是,有有用的信息,但是此响应中的数据在哪里??? I only see metadata...我只看到元数据...
Here is my code:这是我的代码:
import json
import boto3
import botocore
dynamodb = boto3.client("dynamodb")
def get_dict(primary_key):
print("primary_key:",primary_key)
dynamodb = boto3.resource("dynamodb", region_name="eu-west-3")
table = dynamodb.Table("mydynamoname")
response = table.get_item(Key={"creation_file_date": primary_key})
print(response)
return response
def lambda_handler(event, context):
form_dict = get_dict(event["report_id"])
print(form_dict)
return {
'statusCode': 200,
'body': json.dumps(form_dict)
}
Sorry for the bother, I just put the wrong id !!!对不起,打扰了,我刚刚放错了 id!!!
(was loading an old one id and trying to get a new one that I was creating but not already created ^^). (正在加载一个旧的 ID 并试图获得一个我正在创建但尚未创建的新 ID ^^)。 Strange that I don't get an error for that... But I'm fine now !奇怪的是我没有收到错误...但我现在很好! (and maybe others will be knowing that ! (也许其他人会知道这一点!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.