[TriLUG] mysql problem

Alan Porter porter at trilug.org
Fri Feb 8 17:07:26 EST 2008


> :|76189-56-5|,|(S)-(-)-2,2'-bis(diphenylphosphino)-1,1'-binaphthyl|
> ...
> load data infile '/home/setup/gunnoe.sql' into table chemical fields
> delimited by '|' terminated by ',' lines starting by ':'

I'm no SQL pro, and so in the past, I have taken a more "old-school"
approach to this kind of problem.

I open the data file in "vi" and edit it (using regexp liberally) until
it resembles valid SQL syntax.  Then I just "mysql < data.sql".

In your case, you would do something like this:

:s/^:/insert into chemical set (x,y,z) values /g
:s/|/"/g

and so on, until the data looks like valid SQL.  When you're done, the
lines should look like this:

insert into chemical set (x,y,z) values ("76189-56-5",",","(S)-(-)-2,2'-bis(diphenylphosphino)-1,1'-binaphthyl");

It's not what you were asking, but it might get your data into the
tables.

Alan






.







More information about the TriLUG mailing list