Created
November 22, 2019 18:09
-
-
Save djg07/301b24c519fcf537dee5567d477f784c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import boto3 | |
from boto3.dynamodb.conditions import Key | |
def lambda_handler(event, context): | |
client = boto3.resource('dynamodb') | |
table = client.Table('Transactions') | |
#1. Example - Get Item By Id | |
response = table.get_item( | |
Key={ | |
'TransactionType_OriginCountry': 'PURCHASE_USA', | |
'Date': '2019-11-17' | |
} | |
) | |
print(response['Item']) | |
print('\n\n\n-----\n\n\n') | |
#2. Example 2 - Query by Partition Key / Sort Key Criteria | |
response = table.query( | |
KeyConditionExpression=Key('TransactionType_OriginCountry').eq('PURCHASE_USA') & Key('Date').gt('2019-11-15') | |
) | |
items = response['Items'] | |
for item in items: | |
print(item) | |
also me :(
I was getting the same error as above. Found out since I was using index on my table, I had to specify...
response = table.query(
IndexName='clientId-meetingDate-index',
KeyConditionExpression=Key('clientId').eq('abc') & Key('meetingDate').gte('2022-05-05')
)
Of course change to your index, and attribute values, but after adding IndexName, all worked well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi , did u resolve this ?
i have the same issue