row = cursor.fetchone() try: print "row[0]:", row[0] except TypeError: print "error"