generated from BloomTech-Labs/template-ds
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
When a google books api call returns with no books, the 'items' key will be missing from the json response. This causes a KeyError
in recommender.py. Error handling here is necessary:
def db_insert(self, isbn=None):
api = GBWrapper()
if isbn is not None:
google_books_response = api.search(isbn)
else:
google_books_response = api.search(self.googleId)
# INSERTS GB_QUERY INTO DATABASE
logging.debug("GETTING API DATA...")
# add error handling for the line below:
api_data = get_value(google_books_response['items'][0])
if isbn is not None:
gid = api_data[0]
details = retrieve_details(google_books_response)
else:
gid = None
details = None
# execute_queries(api_data, self.conn, self.cursor)
execute_queries(api_data, self.conn)
return gid, details
Metadata
Metadata
Assignees
Labels
No labels