1

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?

Jason Strimpel
  • 14,670
  • 21
  • 76
  • 106
  • This shouldn’t be the case - do you have some sample code that we can replicate on a sample table? Its not clear exactly how you’re defining your attributes for updating. And what version of PynamoDB? – Ermiya Eskandary May 25 '22 at 04:02
  • I define my table in Serverless Stack which is an IaC tool. It only allows definition of hash and sort keys - no additional attributes. I am NOT using PynamoDB's Model class (hence my other question you answered). I agree that this should be possible given TableConnection has no concept of a Python model. I am using PynamoDB 5.2.1. – Jason Strimpel May 26 '22 at 01:05
  • I understand, of course. This isn’t reproducible however, do you mind sharing the exact line that you're using? Are you missing any commas or arguments maybe by accident? – Ermiya Eskandary May 26 '22 at 08:14

0 Answers0