catch exceptions from cur.fetchall() too. dedup try:except: blocks