(文件)数据上的PyMySQL错误/异常加载到远程MySQL实例

dec*_*tle 0 python mysql mysql-python python-db-api

我正在使用PyMySQL-0.5.0,并且在将数据从文件加载到远程MySQL实例时遇到晦涩的错误/异常。在执行“LOAD DATA LOCAL INFILE ...”语句中,我看到上面写着一个例外:The used command is not allowed with this MySQL version

任何提示,如果PyMySQL完全支持此操作(和/或其他一些版本支持)

PS:

1)错误详细信息:

2012-05-17 11:05:24,524 - 8988 - DEBUG - Loading table table_2012_05_16 
from file: /path/to/data/file_2012-05-16
2012-05-17 11:05:24,524 - 8988 - DEBUG - Executing update: load data local 
infile '/path/to/data/file_2012-05-16' into table table_2012_05_16(@dummy, c1, 
c2, c3, c4, c5, c6, c7);
2012-05-17 11:05:24,528 - 8988 - ERROR - Exception while executing update: 
<class 'pymysql.err.InternalError'> - (1148, u'The used command is not allowed 
with this MySQL version')
Run Code Online (Sandbox Code Playgroud)

2) 关于“加载数据本地文件...”支持/语法的MySQL文档。

3)如果我使用mysql客户端,则此数据加载工作正常(即恕我直言,对此加载不应有任何障碍-权限,特权,所拥有的一切):

load_machine:~$ mysql -htarget_machine.baz -ufoo -pbar db -e "load data local 
infile '/path/to/data/file_2012-05-16' into table table_2012_05_16(@dummy, c1, 
c2, c3, c4, c5, c6, c7)"

load_machine: ~$ mysql -htarget_machine.baz -ufoo -pbar db -e "select count(*) 
from table_2012_05_16;"
+----------+
| count(*) |
+----------+
| 38563191 |
+----------+
Run Code Online (Sandbox Code Playgroud)

小智 6

PYMySQL确实支持,LOAD DATA LOCAL INFILE但是必须在数据库连接参数中启用它。例:

connection = pymysql.connect(host='localhost', user='username', password='password', database='databasename', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor, local_infile=True)
Run Code Online (Sandbox Code Playgroud)

默认设置为False