[英]How do I query from dynamoDB with 2 primary key
I have below query to data from my dynamoDB.我对来自我的 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?
如果 id = 1 或 id = 2,我需要查询同一个表。如何在 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 ).查看 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.
它将让您指定要从 Dynamo 检索的主键列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.