amazon web services - DynamoDB scan() ResultSet has no attribute keys -


i'm querying 2 dynamo db tables using scan items inside, storing them in list, , returning them ( within flask app). pretty simple, nothing fancy.

the issue 1 works without issue, other this:

for entry in squads_info: file "/usr/local/lib/python2.7/site-packages/boto/dynamodb/layer2.py", line 125, in __iter__ response = self.response file "/usr/local/lib/python2.7/site-packages/boto/dynamodb/layer2.py", line 92, in response return self.next_response() if self._response none else self._response file "/usr/local/lib/python2.7/site-packages/boto/dynamodb/layer2.py", line 104, in next_response self._response = self.callable(**self.kwargs) file "/usr/local/lib/python2.7/site-packages/boto/dynamodb/layer1.py", line 577, in scan return self.make_request('scan', json_input, object_hook=object_hook) file "/usr/local/lib/python2.7/site-packages/boto/dynamodb/layer1.py", line 127, in make_request return json.loads(response_body, object_hook=object_hook) file "/usr/local/lib/python2.7/json/__init__.py", line 351, in loads return cls(encoding=encoding, **kw).decode(s) file "/usr/local/lib/python2.7/json/decoder.py", line 366, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) file "/usr/local/lib/python2.7/json/decoder.py", line 382, in raw_decode obj, end = self.scan_once(s, idx) file "/usr/local/lib/python2.7/site-packages/boto/dynamodb/types.py", line 347, in decode return decoder(attr[dynamodb_type]) file "/usr/local/lib/python2.7/site-packages/boto/dynamodb/types.py", line 377, in _decode_l return [self.decode(i) in attr] file "/usr/local/lib/python2.7/site-packages/boto/dynamodb/types.py", line 338, in decode dynamodb_type = list(attr.keys())[0] attributeerror: 'unicode' object has no attribute 'keys' 

here code first scan:

def get_browsers():     # database table instance can scanned     browsers = get_table_connection('browser')     # list of environments in table     browser_list = []     # getting full list of environments in table     results = browsers.scan()     # add dictionary entry each result    result in results:        entry = {            "name": result['name'],            "versions": result['versions']         }          browser_list.append(entry)     # return env_list     return jsonify(result=browser_list) 

and here failing scan code.

@logger_app.route("/squad-information", methods=['get']) def get_squad_info():    # connection db    squads = get_table_connection('squad')     # need return information have stored in table,    scan should    squads_info = squads.scan()      # start building response    # response array of dictionaries    response = []     entry in squads_info:       response_entry = {           "name": entry['name'],           "squad_id": entry['squad_id'],           "test_suites": entry['test_suites']       }        response.append(response_entry)  return jsonify(squads=response) 

both tables have @ least 1 element within them. difference first returns result, whereas second doesn't. more appreciated. cheers!

the issue using dynamodb version 1 (i.e. deprecated one). once switched connecting new version of table , performed scan appropriate method, worked.

hope helps other tormented souls confused cross-version mismatches.


Comments