使用pynamodb放置一个具有新属性的项目
我有通过基础结构-AS代码实现创建的现有DynamoDB表。
我使用tableConnection连接到现有表并运行下级命令put_item
。
我的表由Hash键(userId
)定义,然后对键(transActionId
)定义。
我想放置一个带有其他属性的项目(timestamp
,符号
,nature
)。
我没有定义这些其他属性。
当我运行以下命令时:
table = TableConnection('ExistingTable')
table.put_item(user_id, transaction_id, attributes={...})
我会收到以下错误:
value error:['userId','transactionId']
中没有属性时间戳
。
I have existing DynamoDB tables created through an infrastructure-as-code implementation.
I used TableConnection to connect to the existing table and run the lower level command put_item
.
My table is defined with a hash key (userId
) and sort key (transactionId
).
I want to put an item with additional attributes (timestamp
, symbol
, quantity
).
I have not defined these additional attributes.
When I run the following command:
table = TableConnection('ExistingTable')
table.put_item(user_id, transaction_id, attributes={...})
I receive the following error:
ValueError: No attribute timestamp in ['userId', 'transactionId']
How do I put an item without defining the attributes previously?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
昨天我遇到了完全相同的问题,在揉了揉头几个小时后,我终于发现,使用此低级API时,我们必须使用 attributeValue 指定其他属性(包括相应的数据类型)。
因此,您可能应该写这样的东西:
I encountered the exact same issue yesterday and after rubbing my head for hours, I've finally figured out that when using this low level API, we must use the format of AttributeValue to specify the additional attributes (including the corresponding data type).
So it's likely you're supposed to write something like this: