Automate transfer of csv file to MySQL

前端 未结 3 796
天命终不由人
天命终不由人 2021-01-07 05:27

I have a csv file that I will be regularly updating through a batch script that calls cygwin+ bash script. I would like to automate the upload of the csv file into a

3条回答
  •  旧时难觅i
    2021-01-07 06:02

    You can use Quartz to create a cronjob - for periodically updating your database. with the help of cronmaker (http://www.cronmaker.com/), you get to choose when and how often your database gets updated.

    This is a sample SQL Script to import data into your MySQL database:

    LOAD DATA INFILE 'c:/.../filename.csv' 
    INTO TABLE discounts 
    FIELDS TERMINATED BY ',' 
    ENCLOSED BY '"'
    LINES TERMINATED BY '\n'
    IGNORE 1 ROWS;
    

    run the above script in your cronjob using your preferred language.

提交回复
热议问题