Problems restoring connection to MySQL server after <2013: Lost connection to MySQL server during query>

Asked by Thomas Karl Pietrowski

After experimenting with this python module I noticed that I can't query my table on my NAS over the internet.
It fetches just 200 rows and throws

2013: Lost connection to MySQL server during query

So I decided to make a workaround for that to recover the connection e.g. via .reconnect(), but this didn't work and I browsed the code and made a manual reconnect via disconnect() and connect().

So, the result was this traceback:
   File "/home/thopiekar/Projekte/eclipse/OBDX_LOOKUP_mobile/src/", line 178, in reconnect_remote
   File "/usr/lib/pymodules/python2.7/mysql/connector/", line 326, in connect
   File "/usr/lib/pymodules/python2.7/mysql/connector/", line 305, in _post_connection
   File "/usr/lib/pymodules/python2.7/mysql/connector/", line 828, in set_charset_collation
     charset_name, collation_name))
   File "/usr/lib/pymodules/python2.7/mysql/connector/", line 1105, in _execute_query
     raise errors.InternalError("Unread result found.")
 mysql.connector.errors.InternalError: Unread result found.

After that I browsed the code for functions which might [Cursor].reset() or whatever to fix that problem, but nothing helped..

Could you give me a hint to fix that? It would be great!

(using Ubuntu Raring + latest mysql connector for python using my build at

Question information

English Edit question
MySQL Connector/Python Edit question
No assignee Edit question
Solved by:
Geert JM Vanderkelen
Last query:
Last reply:
Revision history for this message
Best Geert JM Vanderkelen (geertjmvdk) said :

You can not tell MySQL to forget about a result set. You need to either:
1) Fetch the result after the query,
2) use Buffered cursor so the result is fetch right away (might be best with small results),
3) or you can disconnect (and reconnect) like you mentioned.

The 'Unread result found' should be handled by the application and make sure the results are read before executing any new statement.

Mentioning 'latest' is not specific enough. The latest at the time of writing and the time the question was asked is v1.0.8, which can be downloaded from the website. (Launchpad might lag behind when syncing.)

Revision history for this message
Thomas Karl Pietrowski (thopiekar) said :

Well, I'm doing a disconnect() before connect() and it still happens.

In addition I tried to to a .fetch*() after [here: .fetchall() ], to get it work, but when doing this I get:
> No result set to fetch from.

I'll test now the last option you mentioned using a buffered cursor, even if it is a big table.

By the way: Where is the latest code hosted? GitHub?

Revision history for this message
Geert JM Vanderkelen (geertjmvdk) said :

If you can reproduce it with a (smaller) test case, please open a bug report on It looks a bit odd..

(We push to Launchpad after release, but it can lag a bit.)

Revision history for this message
Thomas Karl Pietrowski (thopiekar) said :

Well, this problem seems to be fixed in the latest (1.0.8) version which can be found on

Additionally: Could you sync the code with trunk at launchpad? I would like to make a updated package for it.

Revision history for this message
Thomas Karl Pietrowski (thopiekar) said :

Thanks Geert JM Vanderkelen, that solved my question.