简体   繁体   中英

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
            }
        ]
    )

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM