MySQL LOAD DATA LOCAL INFILE Python

后端 未结 3 659
无人共我
无人共我 2020-12-08 21:04

I am running Ubuntu 12.04 and MySQL 5.5 Alright so here is the problem:

Using the MySQLDB module for Python, the SQL command:

cursor.execute(\"LOAD D         


        
3条回答
  •  抹茶落季
    2020-12-08 21:56

    As I see, there is no file option local-infile. But you can change this value dynamically in a script.

    To view this option run this query -

    SELECT @@global.local_infile;
    

    To set variable use this statement -

    SET @@global.local_infile = 1;
    

    Tested in MySQL command line console, everything is OK:

    SET @@GLOBAL.local_infile = 1;
    LOAD DATA LOCAL INFILE 'test.csv' INTO TABLE table1;
    Query OK, 3 rows affected (0.06 sec)
    
    SET @@GLOBAL.local_infile = 0;
    LOAD DATA LOCAL INFILE 'test.csv' INTO TABLE table1;
    ERROR 1148 (42000): The used command is not allowed with this MySQL version
    

提交回复
热议问题