[英]Python Boto3 AWS DynamoDB get item from table without sort key
I am trying to update an item from my DynamoDb table from a AWS Lambda function and I am getting the following error: 我正在尝试通过AWS Lambda函数从DynamoDb表中更新项目,并且出现以下错误:
"errorMessage": "An error occurred (ValidationException) when calling the UpdateItem operation: The provided key element does not match the schema",
“ errorMessage”:“调用UpdateItem操作时发生错误(ValidationException):提供的键元素与架构不匹配”,
I have not defined a sort key when defining my table, and my partition key is named 'pipeId', and I have used the following code: 定义表时,我尚未定义排序键,并且分区键名为“ pipeId”,并且使用了以下代码:
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('mytable')
response = table.update_item(
Key={
'pipeId': pipe_id
},
UpdateExpression="set hookId = :r",
ExpressionAttributeValues={
':r': hook_id
},
ReturnValues="UPDATED_NEW"
)
Isn't possible to get or update an item without previously setting a sort key ? 如果没有事先设置排序键就无法获取或更新商品? or am I doing something wrong here ?
还是我在这里做错了什么?
I have found the solution. 我找到了解决方案。
The problem was that my primary key is defined as number and I was inserting it as String, like "3219"; 问题是我的主键定义为数字,而我将其插入为字符串,例如“ 3219”; but it doesn't convert automatically.
但它不会自动转换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.