mysql自己有个csv引擎,可以通过这个引擎来实现将csv中的数据导入到mysql数据库中,并且速度比通过php或是python写的批处理程序快的多。
具体的实现代码示例:
复制代码 代码如下:
load data infile '/tmp/file.csv' into table _tablename (set character utf8)
fields terminated by ','
enclosed by '"'
lines terminated by '\r\n';
复制代码 代码如下:
select * from tablename into outfile '/tmp/data.txt'
fields terminated by ','
optionally enclosed by '"'
lines terminated by '\n';