the cursor.execute method sometimes returns 18446744073709551615 when an error occurs during the execution of a SQL statement. in our case, we were executing a SELECT query. the MySQLdb implementation of the affected_rows method converts a unsigned long long to a python long. when mysql_affected_rows returns (my_ulonglong)-1, the MySQLdb converts this to 18446744073709551615.
It would be nice if the MySQLdb affected_rows method returns a -1 rather than this positive integer.