Mxvii
Mxvii

Reputation: 67

Is there a way to get primary key values from dynamodb without knowing the value?

I am trying to query my DynamoDB table based on multiple primary keys in the table. I want it to then return the value based on the primary key. I am using boto3 python sdk to write a script to retrieve this information.

However, the problem I am coming across is it seems that all the calls to DynamoDb I am looking at requires that you know the value of the partition key as well.

For example, batch get item says I can do this using an attribute; however, it the example it has a key and a value passed in the request. https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchGetItem.html

Does anyone know if this is possible?

Upvotes: 1

Views: 1997

Answers (1)

jarmod
jarmod

Reputation: 78918

If you don't know any part of your item's key then the scan operation will return all items.

If your table has a composite key (partition key and sort key) and you know at least the partition key value of interest, then a query on the partition key alone will return all items with a matching partition key i.e. it will return multiple items if there are multiple matching items (with different sort keys).

Upvotes: 0

Related Questions