Automate transfer of csv file to MySQL

前端 未结 3 805
天命终不由人
天命终不由人 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条回答
  •  情深已故
    2021-01-07 06:11

    You can execute a MySQL script from the command line by doing something like:

    mysql -uUsername -pPassword database_name < infile.sql
    

    You could invoke that from the command line and in the infile.sql you could have code like:

    LOAD DATA INFILE 'filename.csv' TO table_name 
    FIELDS TERMINATED BY ','
    

提交回复
热议问题