Hello,
I'm assuming I can post issues regarding MySQL Connector/Python here. Any help in debugging this issue is appreciated. I'm afraid though that it's caused by my environment, making it harder to reproduce. Let me know if you need any additional information.
Basically, I installed MySQL Connector/Python without a problem on CentOS 5.4, using Python 2.7.7. I'm able to import mysql.connector and initialize a connection using mysql.connector.connect(). According to the is_connected method, I'm indeed connected to the database.
However, as soon as I execute any SQL query, whether by using a cursor object or something else that runs a SQL command behind the scenes (e.g. get_database method), I run into the following error:
mysql.connector.errors.InterfaceError: Failed parsing EOF packet.
Apparently, the database connection is lost after this, according to the is_connected method. Below is a copy of an interactive Python session showing this. N.B. I'm using the Anaconda Python distribution here, but the same issue exists with a vanilla installation of Python.
>>> import mysql.connector
>>> cnx = mysql.connector.connect(<database information here>)
>>> cnx.is_connected()
True
>>> cnx.get_database()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 1200, in get_database
return self._info_query("SELECT DATABASE()")[0]
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 1434, in _info_query
cursor.execute(query)
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/cursor.py", line 494, in execute
self._handle_result(self._connection.cmd_query(stmt))
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 683, in cmd_query
statement))
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 612, in _handle_result
eof = self._handle_eof(self._socket.recv())
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 554, in _handle_eof
eof = self._protocol.parse_eof(packet)
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/protocol.py", line 252, in parse_eof
raise errors.InterfaceError(err_msg)
mysql.connector.errors.InterfaceError: Failed parsing EOF packet.
>>> cnx.get_database()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 1200, in get_database
return self._info_query("SELECT DATABASE()")[0]
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 1433, in _info_query
cursor = self.cursor(buffered=True)
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 1328, in cursor
raise errors.OperationalError("MySQL Connection not available.")
mysql.connector.errors.OperationalError: MySQL Connection not available.
>>> cnx.is_connected()
False
I'm assuming I can post issues regarding MySQL Connector/Python here. Any help in debugging this issue is appreciated. I'm afraid though that it's caused by my environment, making it harder to reproduce. Let me know if you need any additional information.
Basically, I installed MySQL Connector/Python without a problem on CentOS 5.4, using Python 2.7.7. I'm able to import mysql.connector and initialize a connection using mysql.connector.connect(). According to the is_connected method, I'm indeed connected to the database.
However, as soon as I execute any SQL query, whether by using a cursor object or something else that runs a SQL command behind the scenes (e.g. get_database method), I run into the following error:
mysql.connector.errors.InterfaceError: Failed parsing EOF packet.
Apparently, the database connection is lost after this, according to the is_connected method. Below is a copy of an interactive Python session showing this. N.B. I'm using the Anaconda Python distribution here, but the same issue exists with a vanilla installation of Python.
>>> import mysql.connector
>>> cnx = mysql.connector.connect(<database information here>)
>>> cnx.is_connected()
True
>>> cnx.get_database()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 1200, in get_database
return self._info_query("SELECT DATABASE()")[0]
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 1434, in _info_query
cursor.execute(query)
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/cursor.py", line 494, in execute
self._handle_result(self._connection.cmd_query(stmt))
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 683, in cmd_query
statement))
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 612, in _handle_result
eof = self._handle_eof(self._socket.recv())
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 554, in _handle_eof
eof = self._protocol.parse_eof(packet)
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/protocol.py", line 252, in parse_eof
raise errors.InterfaceError(err_msg)
mysql.connector.errors.InterfaceError: Failed parsing EOF packet.
>>> cnx.get_database()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 1200, in get_database
return self._info_query("SELECT DATABASE()")[0]
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 1433, in _info_query
cursor = self.cursor(buffered=True)
File "/home/bgrande/software/genesis/anaconda-2.0.1/lib/python2.7/site-packages/mysql/connector/connection.py", line 1328, in cursor
raise errors.OperationalError("MySQL Connection not available.")
mysql.connector.errors.OperationalError: MySQL Connection not available.
>>> cnx.is_connected()
False