DynamoDB model is out of date?
See original GitHub issueIt looks like specifying hash keys and range keys separately is now deprecated. The new way is to specify them together.
This is how the problem exhibits itself on my side:
items = self.dbclient.batch_get_item(
RequestItems={
self.urls_table_name: {
"ConsistentRead": True,
"ExpressionAttributeNames": {"#U": "url"},
"ProjectionExpression": "#U,elastic_id",
"Keys": [{"url": {"S": u}} for u in urls]
}
}
)
The above code ends up tripping over KeyError: u’HashKeyElement’.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How it works: DynamoDB Time to Live (TTL)
Learn about working with Time to Live (TTL) in DynamoDB and what you need to know to ... TTL typically deletes expired items...
Read more >What data type should be used for timestamp in DynamoDB?
The String data type should be used for Date or Timestamp. You can use the String data type to represent a date or...
Read more >How-To Work With Timestamps in DynamoDB [Ultimate Guide]
I'd highly encourage you to check out that guide if you have data that needs to be deleted from your database based on...
Read more >Beware of Dynamodb TTL - Bibhuti Poudyal - Medium
DynamoDB typically deletes expired items within 48 hours of expiration. The exact duration within which an item truly gets deleted after ...
Read more >The Ten Rules for Data Modeling with DynamoDB - Trek10
But modeling your data in DynamoDB is significantly different ... DynamoDB Time-to-Live (TTL) to automatically expire items from your table.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@crbunney It looks like you’re using the old API version of DynamoDB. Are you getting the same error with
@mock_dynamodb2
?No, not when I use
@mock_dynamodb2
(found that suggestion on the different issue after I posted this)Although, I find it a bit counterintuitive. There’s no dynamodb2 in boto3 (only in prior boto versions) and for other usages, the argument passed to the resource/client call matches the mock decorator (e.g.
resource('dynamodb')
implies using@moto.mock_dynamodb
, not@moto.mock_dynamodb2
)So it looks like the old API has been completely deprecated in boto3 and replaced with the “new” API (although the new one isn’t really new any more, it’s been around for, what, 5 years?)