[英]Python mysqldb error closing connection
I'm having a problem when closing a connection as follows: 关闭连接时出现问题,如下所示:
database = 'sed_database'
conn = MySQLdb.Connect(host='remote_host', user='default',
passwd='pass', db=database)
try:
try:
cursor = conn.cursor()
cursor.execute(sql_str)
results = cursor.fetchall()
except MySQLdb.Error, e:
print "MySQL/Server Error using query: %s" % sql_str
print "Using database: %s" % database
raise e
finally:
if cursor:
cursor.close()
if conn:
conn.close()
This gives: 这给出:
Traceback (most recent call last):
File "trass.py", line 579, in ?
main(sys.argv)
File "trass.py", line 555, in main
old_rows, changes_list = auto_analyse_test(f, args.build, args.quiet, args.debug)
File "trass.py", line 352, in auto_analyse_test
last_analysed_build = get_sed_baseline_ref(test_file_name, old_delivery_stream)
File "trass.py", line 151, in get_sed_baseline_ref
results = execute_sql_query(sql, delivery_stream)
File "trass.py", line 197, in execute_sql_query
passwd='pass', db=database)
File "C:\Python24\Lib\site-packages\MySQLdb\__init__.py", line 75, in Connect
return Connection(*args, **kwargs)
File "C:\Python24\Lib\site-packages\MySQLdb\connections.py", line 164, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.InternalError: (3, "Error writing file 'D:\\MySQL_Datafiles\\Logfiles\\query.
log' (Errcode: 9)")
Python's MySQLDB library info is as follows: Python的MySQLDB库信息如下:
>>> print MySQLdb.get_client_info()
4.1.18
>>> print MySQLdb.__version__
1.2.1_p2
>>> print MySQLdb.__revision__
410
What is strange is that: 奇怪的是:
The server error.log says "Aborted connection... (Got an error reading comminication packets)" 服务器error.log中显示“连接中断...(读取通讯包时出错)”
While the Traceback appears to show the error being associated with the connection creation, it doesn't occur until the connection is closed (or the function ends, which I guess closes it by default). 虽然“回溯”似乎显示与连接创建相关的错误,但直到关闭连接(或函数结束,我猜默认情况下会关闭),该错误才会发生。 I've tried putting extra output or pauses between open and close.
我尝试在打开和关闭之间放置额外的输出或暂停。 Every time the exception occurs on the close.
每当关闭时发生异常。 So what could cause this error on closing the connection?
那么关闭连接时可能导致此错误的原因是什么?
Here's what I found so far. 这是我到目前为止发现的。
It appears that error is triggered when opening a connection, at MySQLdb.Connect(...)
, 2nd line in pasted code, not when closing a connection. 似乎在
MySQLdb.Connect(...)
粘贴代码中的第二行MySQLdb.Connect(...)
打开连接时触发了错误,而不是在关闭连接时触发了错误。
Full backtrace: 完整回溯:
Let's decode the exception 让我们解码异常
InternalError:
(3,
"Error writing file 'D:\\MySQL_Datafiles\\Logfiles\\query.log'
(Errcode: 9)")
EE_WRITE
3 EE_WRITE
3 ERROR_INVALID_BLOCK
"The storage control block address is invalid." ERROR_INVALID_BLOCK
”存储控制块地址无效。“ Quite cryptic, but it'd go and check if this file exist, if it is writeable, and if it may be subject to logrotate or similar. It appears to be a client-side error. 它似乎是客户端错误。 Please check your client-side
my.cnf
, [client]
section. 请检查您的客户端
my.cnf
[client]
部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.