Python在读写远程MySql数据库时,在数据量略大时(约4000条),总是运行一段时间后,过程中出现:OperationalError: MySQL Connection not available,查看代码与cursor = conn.cursor()有关。 网上查了些资料,与MySql的固有bug有关(http://bugs.mysql.com/bug.php?id=67649):
1
2
3
4
5
6
7
8
Description:
If you open an unbuffered cursor and you do not read the WHOLE result set before closing the cursor, the next query will fail with
File "/usr/lib/python3.2/site-packages/mysql/connector/connection.py", line 1075, in cursor
raise errors.OperationalError("MySQL Connection not available.")
mysql.connector.errors.OperationalError: MySQL Connection not available.