简体   繁体   English

Python Boto3 AWS DynamoDB从表中获取项目而无排序键

[英]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.

相关问题 AWS Lambda Python Boto3 - 项目计数 dynamodb 表 - AWS Lambda Python Boto3 - Item count dynamodb table 无法解析 AWS DynamoDB 二进制获取 boto3 python 中的项目 - Unable to parse AWS DynamoDB binary get item in boto3 python AWS DynamoDB-Boto3从dynamoDB表/结构中获取所有属性,字段名称,列标题 - AWS DynamoDB - Boto3 get all attributes, fieldnames, column headers from a dynamoDB table / structure AWS DynamoDB Python - 无法识别boto3 Key()方法(查询) - AWS DynamoDB Python - boto3 Key() methods not recognized (Query) 如何使用Python boto3从AWS DynamoDB表中获取特定属性的所有项目? - How to fetch all items of a particular Attribute from an AWS DynamoDB Table using Python boto3? 在不使用 boto3 的情况下改变 DynamoDB 中的表 - Mutate table in DynamoDB without using boto3 BOTO3 DynamoDB 错误:从 dynamodb 表的 LIST 属性中删除项目 - BOTO3 DynamoDB error: delete an item from a LIST attribute in a dynamodb table AWS Lambda Boto3 python - dynamodb 表上的过滤器表达式抛出错误“errorMessage”:“名称'Attr'未定义”, - AWS Lambda Boto3 python - filter expression on dynamodb table throw error "errorMessage": "name 'Attr' is not defined", AWS DynamoDB 使用 Python/Boto3/Lamba 更新整数计数器 - AWS DynamoDB update integer counter with Python/Boto3/Lamba 将 AWS DynamoDB 数据转换为 Python/Boto3/Lamba 中的 json 格式 - AWS DynamoDB data to json format in Python/Boto3/Lamba
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM