Python boto3 dynamodb put_item()错误仅接受关键字参数
我在lambda函数中使用bot3将信息写入dynamodb表 我得到错误Python boto3 dynamodb put_item()错误仅接受关键字参数,python,amazon-web-services,aws-lambda,amazon-dynamodb,boto3,Python,Amazon Web Services,Aws Lambda,Amazon Dynamodb,Boto3,我在lambda函数中使用bot3将信息写入dynamodb表 我得到错误put\u item()只接受关键字参数 在网上搜索时,我发现这个错误可能意味着我没有匹配dynamodb分区密钥,但在我看来,我做的一切都是正确的 有人能帮我找到错误吗?对不起,这是我第一次使用aws 这是我的lambda函数 import json, boto3 def updateDynamo(Item): dynamodb = boto3.resource('dynamodb', region_name
put\u item()只接受关键字参数
在网上搜索时,我发现这个错误可能意味着我没有匹配dynamodb分区密钥,但在我看来,我做的一切都是正确的
有人能帮我找到错误吗?对不起,这是我第一次使用aws
这是我的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!')
}
这是我正在使用的测试事件:
{
"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": {}
}
我的表有email
(所有字符都是小写)作为分区键。只需要关键字参数。这意味着,在您的情况下,而不是:
response = table.put_item(Item)
应该有
response = table.put_item(Item=Item)
我本来打算这么做的,但系统告诉我需要2分钟来接受它。我会的,别担心。