Python/MySQL: No data - zero rows fetched, selected, or processed
I'm calling a MySQL function via Python (Django) and get the error "No data - zero rows fetched, selected, or processed." I have seen the solutions that involve making a dummy query so that at least one row is selected. This worked great for me until I moved my project to a different server with different versions. Now I get the error whenever ANY query returns null.

In the code below: If function 1 contains only query 1 (always returns a value) then it's fine. However if it contains both query 1 and query 2 (q2 does not find a value) then I get the error. There are no MySQL cursors involved.
    
   PYTHON:
   
     cursor.execute("select function_1() from my_first_table where page = 1")
     cursor.fetchall()
   
   MYSQL:
   
    function_1()
     
        -- query 1 that finds a value
        select ... 
        
        -- query 2 that does not find a value
        select ....
     
        return 1;

I tried just suppressing the errors via Python

    import warnings
    warnings.filterwarnings("ignore", "No data.*") 

But that was bad. It suppressed actual errors and gave me the wrong response when cursors were involved and I didn't have the needed dummy query.  

I can "fix" the error by including an error handler in function_1:  

    declare continue handler for 1329 do_something;

However I prefer to understand and avoid errors, not catch them haphazardly. And I would have to add it to lots of code, making sure that the handler did something appropriate. Also, I'm afraid that I will suppress actual errors, for example, when I still need the dummy query (cursors).

  
I am using Python: 2.6.8 MySQL: 5.0.05 Django: 1.2.4  

The traceback is:

    cursor.execute("select function_1() from my_first_table where page = 1") 

    /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) 


Python/MySQL: No data - zero rows fetched, selected, or processed
===

I'm calling a MySQL function via Python (Django) and get the error "No data - zero rows fetched, selected, or processed." I have seen the solutions that involve making a dummy query so that at least one row is selected. This worked great for me until I moved my project to a different server with different versions. Now I get the error whenever ANY query returns null.

In the code below: If function 1 contains only query 1 (always returns a value) then it's fine. However if it contains both query 1 and query 2 (q2 does not find a value) then I get the error. There are no MySQL cursors involved.
    
   PYTHON:
   
     cursor.execute("select function_1() from my_first_table where page = 1")
     cursor.fetchall()
   
   MYSQL:
   
    function_1()
     
        -- query 1 that finds a value
        select ... 
        
        -- query 2 that does not find a value
        select ....
     
        return 1;

I tried just suppressing the errors via Python

    import warnings
    warnings.filterwarnings("ignore", "No data.*") 

But that was bad. It suppressed actual errors and gave me the wrong response when cursors were involved and I didn't have the needed dummy query.  

I can "fix" the error by including an error handler in function_1:  

    declare continue handler for 1329 do_something;

However I prefer to understand and avoid errors, not catch them haphazardly. And I would have to add it to lots of code, making sure that the handler did something appropriate. Also, I'm afraid that I will suppress actual errors, for example, when I still need the dummy query (cursors).

  
I am using Python: 2.6.8 MySQL: 5.0.05 Django: 1.2.4  

The traceback is:

    cursor.execute("select function_1() from my_first_table where page = 1") 

    /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) 

