Created
May 28, 2020 19:08
-
-
Save mholmes-hs/3cd9f75141a2eb619af0f7492d87afcc to your computer and use it in GitHub Desktop.
Query example using GSI
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 boto3 | |
from boto3.dynamodb.conditions import Key | |
def query_data_with_gsi(): | |
dynamodb = boto3.resource('dynamodb') | |
table = dynamodb.Table('Employees') | |
response = table.query( | |
IndexName='email', | |
KeyConditionExpression=Key('email').eq('jdoe@test.com') | |
) | |
print(response['Items'][0]) | |
#{'last_name': 'Doe', 'email': 'jdoe@test.com', 'first_name': 'Jon', 'emp_id': Decimal('1')} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment