I am having problems with the error “No data – zero rows fetched, selected, or processed.”
I have shortened my question to this since the answer below describes the problem as well as possible solutions.
The traceback was:
cursor.execute("select function_1() from dual")
/django/lib/python2.6/django/db/backends/util.py in execute
15. return self.cursor.execute(sql, params)
/django/lib/python2.6/django/db/backends/mysql/base.py in execute
86. return self.cursor.execute(query, args)
usr/local/lib/python2.6/site-packages/MySQLdb/cursors.py in execute
176. if not self._defer_warnings: self._warning_check()
/usr/local/lib/python2.6/site-packages/MySQLdb/cursors.py in _warning_check
92. warn(w[-1], self.Warning, 3)
I have spent a long time dealing with the problem: “No data – zero rows fetched, selected, or processed”. I realized that part of the issue is that different versions of MySQL (or perhaps of Django and Python) cause different behaviors. I don’t think that this is specific to Python or Django, but don’t know. I don’t know if it has to do with some variables that are set up, as opposed to something inherent in the different versions.
The two sets of versions are:
What I do:
In Python (via Django):
Definitions:
In VERSION SET1
CASE 1a: Python calls function_1 whose LAST query returns NULL. We get the error.
CASE 1b: Python calls function_1, which calls function2. There are no mysql cursors. If function2’s LAST query returns null: Function2 is still properly evaluated and returns proper value to function1.
CASE 1c: Python calls function_1, which opens a cursor that makes a call to function2 (either inside the cursor loop or in the cursor select itself). If function2’s LAST query returns null: THIS IS BAD. The cursor is immediately closed and function_1 continues as though the cursor had been evaluated. There are no warnings.
In conclusion for VERSION SET1:
In VERSION SET2
CASE 2a: Python calls function_1 where ANY query returns NULL. We get the error.
CASE 2b: Python calls function_1, which calls function2. There are no mysql cursors. If function2s has ANY query that returns null: We get the error.
CASE 2c: Python calls function_1, which opens a cursor that makes a call to function2 (either inside the cursor loop or
in the cursor select itself). If function2 has ANY query that returns null: We get the error.
In conclusion for version SET2
In conclusion for it to work in BOTH: