jwh20
jwh20

Reputation: 678

BOTO3 only returning only returning partial data from DynamoDB Table

I have a relatively simple DynamoDB table that has a date string as the partition key, a name as a sort key, and a text representation of a JSON document as an attribute named Document.

I'm querying it with this code:

dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('SolarData')

response = table.get_item(
    Key={'StartDate': '2019-07-08', 'InverterName': 'Inverter1'},
)

print(response)

The problem that I'm having is that the response only has about the first 10K bytes of the Document which is about 50K bytes long.

I know that the entire document data is stored as I can see it in the AWS Console and also if I do a get-item from the CLI with this command:

aws dynamodb get-item --table-name SolarData --key "{""StartDate"":{""S"":""2019-07-10""},""InverterName"":{""S"":""Inverter1""}}"

I get the entire document written to the output. So I think the problem is either in my code, like I'm not handling the response correctly, or there is a bug in BOTO3.

I searched through the issues list on the BOTO3 GitHub project but didn't find anything that seemed relevant to this.

Upvotes: 1

Views: 1039

Answers (1)

mgrollins
mgrollins

Reputation: 651

If there is data in your response, then result should be a data structure with an "Item" key. Test for that key.

Since you are able to print some of the result, and after consulting the docs, I would try some introspection at a REPL if you can.

item = response['Item']
dir(item)
len(item)
print(json.dumps(item, indent=4))

I have found these examinations help me get my head around what was returned from an unfamiliar API.

Upvotes: 1

Related Questions