简体   繁体   English

如何使用 2 个主键从 dynamoDB 查询

[英]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.

相关问题 Python - 如何使用主键和排序键在 GSI 上查询 DynamoDB - Python - How to query DynamoDB on GSI using primary and sort key 如何对多列主键进行窗口查询? - How can I do windowed query on multiple columns primary key? python如何查询AWS DynamoDB? - How do I query AWS DynamoDB in python? DynamoDB - 如何指定不是主键的唯一字段? - DynamoDB - How to specify UNIQUE field that is not a PRIMARY key? 在不使用主分区键的情况下查询 DynamoDB 中的所有数据 - Query all data in DynamoDB without using primary partition key 是否在DynamoDB中不传递主键的情况下相当于选择查询? - Equivalent of select query without passing primary key in DynamoDB? 在 SQLAlchemy ORM 中,如何获取用于 session.query().group_by() 的主键列? - In SQLAlchemy ORM, How do I get the primary key columns for use in session.query().group_by()? 我如何从缺少属性的DynamoDB表中删除项目,而无论键如何? - How do I delete items from a DynamoDB table wherever an attribute is missing, regardless of key? Python AWS dynamoDB:如何在非主列上使用过滤器查询元素? - Python AWS dynamoDB: how can I query elements with a filter on not primary column? 检查dynamodb中是否存在主键 - Checking if primary key is existing in dynamodb or not
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM