Skip to content

Instantly share code, notes, and snippets.

@subzero112233
Created September 5, 2020 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save subzero112233/db2a6c2421559affc1219407ef49ec01 to your computer and use it in GitHub Desktop.
Save subzero112233/db2a6c2421559affc1219407ef49ec01 to your computer and use it in GitHub Desktop.
import logging
import boto3
from botocore.exceptions import ClientError, ParamValidationError
dynamodb2 = boto3.resource('dynamodb')
def get_from_dynamodb(table, key):
try:
table = dynamodb2.Table(table)
response = table.get_item(Key=key)
except (ClientError, ParamValidationError) as e:
logging.error(e)
raise
return response.get('Item', {})
print(get_from_dynamodb("SanAntonioSpurs", {"PlayerName": "Manu Ginobili", "JerseyNumber": 20}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment