bash脚本将多个csv导入mysql

时间:2018-10-30 11:37:44

标签: mysql bash csv

我需要从名为/ backups / csv的文件夹中导入csv MAG8000_356905H497_2018-10-30 0202.csv MAG8000_356605H497_2018-10-29 1150.csv

我写了剧本

cd /backups/csvuri
for f in *.csv
do
mysql -u $USER -p$PASSWORD -e "use test" -e "LOAD DATA LOCAL INFILE '"$f"' INTO TABLE debitmetre_mag8000 COLUMNS TERMINATED BY ';' LINES TERMINATED BY '\n';"
done

但是给我错误

ERROR 1059 (42000): Identifier name '1150.csv' INTO TABLE debitmetre_mag8000 COLUMNS TERMINATED BY ';' LINES TERMINATED BY '\n';' is too long
ERROR 1059 (42000): Identifier name '0202.csv' INTO TABLE debitmetre_mag8000 COLUMNS TERMINATED BY ';' LINES TERMINATED BY '\n';' is too long

我不明白我在做什么错,也许文件名太长或引号内的引号不起作用。

0 个答案:

没有答案