Created
September 5, 2020 18:00
-
-
Save subzero112233/db2a6c2421559affc1219407ef49ec01 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 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