Skip to content

Instantly share code, notes, and snippets.

@and2long
Last active January 10, 2022 05:00
Show Gist options
  • Save and2long/4902c4e026e996b1caed575dbee20239 to your computer and use it in GitHub Desktop.
Save and2long/4902c4e026e996b1caed575dbee20239 to your computer and use it in GitHub Desktop.
DDB获取一条数据
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