Skip to content

Instantly share code, notes, and snippets.

@mholmes-hs
Last active May 28, 2020 15:23
Show Gist options
  • Save mholmes-hs/39515b5abfd338f3f9318dac2e4cccef to your computer and use it in GitHub Desktop.
Save mholmes-hs/39515b5abfd338f3f9318dac2e4cccef to your computer and use it in GitHub Desktop.
DynamoDB query examp
import boto3
from boto3.dynamodb.conditions import Key
def query():
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Users')
resp = table.query(
KeyConditionExpression=Key('id').eq(1)
)
if 'Items' in resp:
print(resp['Items'][0])
#{'id': Decimal('1'), 'email': 'jdoe@test.com', 'last_name': 'Doe', 'first_name': 'Jon'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment