Last active
January 10, 2022 05:00
-
-
Save and2long/4902c4e026e996b1caed575dbee20239 to your computer and use it in GitHub Desktop.
DDB获取一条数据
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 json | |
import boto3 | |
session = boto3.Session(profile_name="PROFILE NAME") | |
ddb_client = session.client("dynamodb") | |
table_name = 'Main-nhdgaeyblfgp3gygkcsjpmxvky-dev' | |
challenge_id = '0df3b39d-acb6-4fc9-a3cd-eebf29c8b958' | |
response = ddb_client.get_item( | |
TableName=table_name, | |
Key={ | |
'id': {'S': challenge_id} | |
}, | |
) | |
if 'Item' in response: | |
print(json.dumps(response['Item'])) | |
else: | |
print('no data') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment