Mysql + Shell script

I have a file which contains data in the below form


I need only the first two values in each of the lines in the file which has to be inserted in a database.

I would require this script to run everytime the file is modified. could you tell me how to do this..

probably a shell script..

Who is Participating?
You can use the LOAD DATA INFILE syntax within MySQL to load the data:

LOAD DATA INFILE filename INTO TABLE tablename FIELDS TERMINATED BY ':' (column1, column2, @skip_data);

You would need a shell script to invoke this.  You could save the above into a file called load.sql, and invoke a shell script that contains the following:

mysql --user=user_name --password=pass db_name < load.sql

In terms of invoking it whenever the file changes, that's outside the realm of MySQL, but I'm sure you might be able to do this any number of ways in a shell script.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.