Skip to content

Instantly share code, notes, and snippets.

@mholmes-hs
Created May 28, 2020 16:52
Show Gist options
  • Save mholmes-hs/846d627a8abb336bf5a9eecdad7d67ef to your computer and use it in GitHub Desktop.
Save mholmes-hs/846d627a8abb336bf5a9eecdad7d67ef to your computer and use it in GitHub Desktop.
Scan first and last names in DynamoDB
import boto3
from boto3.dynamodb.conditions import Key
def scan_first_and_last_names():
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Users')
resp = table.scan(ProjectionExpression="first_name, last_name")
print(resp['Items'])
'''
[
{'last_name': 'Doe2', 'first_name': 'Jon'},
{'last_name': 'Doe1', 'first_name': 'Jon'},
{'last_name': 'Doe0', 'first_name': 'Jon'}
]
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment