question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DynamoDB model is out of date?

See original GitHub issue

It 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:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bblommerscommented, May 29, 2020

@crbunney It looks like you’re using the old API version of DynamoDB. Are you getting the same error with @mock_dynamodb2?

0reactions
crbunneycommented, May 29, 2020

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?)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found