I have CSV data files that I want to import into mySQL. I would like to make an insert in a shell script so that it can be automated. However, I'm a little tired of having the username and password clear in the script text
I have the following questions:
Am I uncomfortable with the idea of ββuname / pwd in clear text in a script (anyway around this, or am I too paranoid) ?. Maybe I can only configure the user with the INSERT privelege for the table to be inserted?
The database table (into which the raw data was imported) has a unique key based on the columns of the table. It is also possible that there may be duplicates in the data I'm trying to import. Instead of barfing mySQL (i.e. the whole insert doesn't work), I would instead want to point mySQL to EITHER
(a) UPDATE the line with the new data OR (b) GAME duplicate line.
Regardless of which option I selected, for ENTIRE import, and not for line by line. Are there any flags, etc.? I can go to mysql so that it can behave like (a) OR (b) above
- Can anyone suggest a starting point on how to write such a (bourne) shell script?
source share