I am trying to import a CSV file from to a mysql database from the command line. This will be later incorporated into a Windows batch file.
mysqlimport -u user -puserpw --columns=ID,CID,Alerted --fields-terminated-by=',' --local School Customer.csv
All the data loads into the first column in the Customer table. I want to correctly import data from the CSV to the appropriate column.
CSV Data format:
ID,CID,Alerted
1,CS,N
2,CS,N
3,CS,N
I would like to use mysqlimport since this will be easier to add to a Windows batch file. How can I do this please help?
I had to enclose the values in double quotes "
mysqlimport -u user -puserpw --columns=ID,CID,Alerted --ignore-lines=1 --fields-terminated-by="," --lines-terminated-by="\n" --local School Customer.csv
That fixed it.