test
test

Reputation: 153

How do I query from dynamoDB with 2 primary key

I have below query to data from my dynamoDB. It works fine. I need to query the same table if id = 1 or id = 2. How do I perform this query in python?

dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('user')

   results = table.get_item(
        Key=[
            {
                "id": 1
            }
        ]
    )

Upvotes: 0

Views: 549

Answers (1)

Seth Geoghegan
Seth Geoghegan

Reputation: 5747

Check out the BatchGetItem API ( https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchGetItem.html). It will let you specify a list of primary keys to retrieve from Dynamo.

Upvotes: 2

Related Questions