0

查看 _mysql 文档,我发现:

help(_mysql.connection)
class connection(__builtin__.object)
...
load_infile
  int, non-zero enables LOAD LOCAL INFILE, zero disables

然后,我尝试创建一个连接,我有:

python> _mysql.connection(host = ..., db = ..., user = ..., passwd = ..., load_infile = 1)
TypeError                                 Traceback (most recent call last)
<ipython-input-23-e3878d45fb4e> in <module>()
----> 1 _mysql.connection(host = ..., db = ..., user = ..., passwd = ..., load_infile = 1)
TypeError: 'load_infile' is an invalid keyword argument for this function

我错过了什么?

供参考:

In [25]: _mysql.version_info
Out[25]: (1, 2, 3, 'final', 0)

In [26]: _mysql.get_client_info()
Out[26]: '6.0.0'
4

1 回答 1

1

我假设您正在尝试这样做是因为错误:

_mysql_exceptions.OperationalError: (1148, '此 MySQL 版本不允许使用的命令')

我也为此苦苦挣扎了几个小时,但最终找到了解决方案: MySQLdb.connect(server, username, password, database, cursorclass = MySQLdb.cursors.DictCursor, local_infile = 1)

我知道你的问题是关于 _mysql 而不是 MySQLdb,但根据 mata 的评论,你不应该使用 _mysql

于 2012-10-31T09:05:06.870 回答