使用mysqlimport设置变量

时间:2016-04-04 08:59:11

标签: mysql mysqlimport

我正在将{LOAD DATA INFILE' -query重写为mysqlimport program

自:

LOAD DATA INFILE '/tmp/filename.csv' INTO TABLE my_table
     FIELDS TERMINATED BY ';'
     LINES TERMINATED BY '\n'
     (zipcode, @date_variable, `code`, @time_from, @time_to) 
     SET `date` = STR_TO_DATE(@datevar, '%d-%m-%Y'),
         `timefrom` = CONCAT(@timefromvar, '00'),
         `timeto` = CONCAT(@timetovar, '00');

要:

mysqlimport --host='****' --user='****' --password='****' --port='3306' --local --fields-terminated-by=';' --lines-terminated-by='\n' --columns='pc, @datevar, `code`, @timefromvar, @timetovar' db_name /tmp/my_table.csv

但我似乎无法找到如何设置变量datetimefromtimeto。有谁知道这是否可能?或者我只需要在导入后执行UPDATE查询?

更新 Probably no support yet, look here for a work-arround

0 个答案:

没有答案