#12293: mysql backend raises Warning exceptions for ignorable info notices
---------------------------------------------------+------------------------
          Reporter:  wdoekes                       |         Owner:  nobody     
        
            Status:  closed                        |     Milestone:             
        
         Component:  Database layer (models, ORM)  |       Version:  SVN        
        
        Resolution:  wontfix                       |      Keywords:  mysql 
warnings note
             Stage:  Unreviewed                    |     Has_patch:  1          
        
        Needs_docs:  0                             |   Needs_tests:  0          
        
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Comment (by wdoekes):

 Okay, that works for me. Thanks :)

 A possible implementation for others experiencing the same issue:
 {{{
 class suppressed_sql_notes(object):
     '''
     Pimp a cursor object to suppress SQL notes and re-enable the
     original configuration when done.

     Use this in a with statement, like so:
       with suppressed_sql_notes(connection.cursor()) as cursor:
         cursor.execute('STUFF THAT YIELDS HARMLESS NOTICES')

     See django bug #12293 marked as WONTFIX.
     '''
     def __init__(self, cursor):
         self.cursor = cursor
     def __enter__(self):
         self.cursor.execute('''SET @OLD_SQL_NOTES=@@SQL_NOTES,
 SQL_NOTES=0;''')
         return self.cursor
     def __exit__(self, type, value, traceback):
         self.cursor.execute('''SET sql_not...@old_sql_notes;''')
 }}}

 And those two SQL statements at the beginning and end of your custom SQL
 files.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12293#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to