[英]boto3 dynamodb put_item() error only accepts keyword arguments
I'm using boto3 in a lambda function to write information into a dynamodb table.我在 lambda 函数中使用 boto3 将信息写入 dynamodb 表。
I get the error put_item() only accepts keyword arguments
.我收到错误
put_item() only accepts keyword arguments
。
Searching on the web, i found that this error may mean that I am not matching dynamodb partition key, but it seems to me that I am doing everything correctly.在网上搜索,我发现这个错误可能意味着我没有匹配 dynamodb 分区键,但在我看来我做的一切都是正确的。
Can anyone help me find the error?谁能帮我找出错误? Excuse me but this is my first time using aws.
对不起,这是我第一次使用 aws。
This is my lambda function这是我的 lambda 函数
import json, boto3
def updateDynamo(Item):
dynamodb = boto3.resource('dynamodb', region_name = 'eu-central-1')
table = dynamodb.Table('userInformations')
response = table.put_item(Item)
return response
def lambda_handler(event, context):
userAttributes = event["request"]["userAttributes"]
email = userAttributes["email"]
name = userAttributes["name"]
Item = {
"email": email,
"name" : name
}
response = updateDynamo(Item)
print(email, name)
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
This is the test event i'm using:这是我正在使用的测试事件:
{
"version": "string",
"triggerSource": "string",
"region": "AWSRegion",
"userPoolId": "string",
"userName": "string",
"callerContext": {
"awsSdkVersion": "string",
"clientId": "string"
},
"request": {
"userAttributes": {
"email": "testemail@gmail.com",
"name": "test user"
}
},
"response": {}
}
My table has email
(all char are lowercase) as partition key.我的表有
email
(所有字符都是小写)作为分区键。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.