i'm using Python with MySQL and Django. I keep seeing this error and I can't figure out where the exception is being thrown:
Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") in <bound method Cursor.__del__ of <MySQLdb.cursors.Cursor object at 0x20108150>> ignored
I have many "try" and "exception" blocks in my code--if the exception occurred within one of those, then I would see my own debugging messages. The above Exception is obviously being caught somewhere since my program does not abort when the Exception is thrown.
I'm very puzzled, can someone help me out?
MySqlException Class. The exception that is thrown when MySQL returns an error. This class cannot be inherited. Inheritance Hierarchy. System.
InterfaceError: When database connection fails for some reason, MySQLdb will raise an InterfaceError. Note InterfaceError only get raise when there is internal problem in connection to the database, MySQLdb will not raise InterfaceError because of wrong database name or password.
Handling Warnings By default, MySQL Connector/Python neither fetch warnings nor raise an exception on warnings. But, we can change that using the following arguments of the connect() function. If set to True warnings are fetched automatically after each query without having to manually execute SHOW WARNINGS query.
I had exactly that error (using MySQLdb and Django) and discovered that the reason it was "ignored" was that it occurred in a __del__
method. Exceptions in __del__
are categorically ignored:
object.__del__
datamodel
There doesn't seem to be any way to catch it from further up the stack (at least according to this thread), but you can edit MySQLdb/cursors.py or monkey-patch to get your own __del__
in there that catches the exception and drops you into a pdb prompt or logs a full traceback.
This is a Python Error.
See: http://eric.lubow.org/2009/python/pythons-mysqldb-2014-error-commands-out-of-sync/
It looks like there is a problem with your MySQLdb Query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With