要执行的sql
把csvload进db
LOAD DATA LOCAL INFILE '/path/datas/temp.csv' INTO TABLE test_table_name FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '
' IGNORE 1 ROWS;
把客户端和server端 local_infile 都设置为True/ON
# server端
mysql> SHOW VARIABLES LIKE '%local%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile | ON |
+---------------+-------+
# 客户端
connect = pymysql.connect(host=host, user=user_name, passwd=password, db=db_name, charset='utf8', local_infile=True)