Hammer2001 has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to use MySQL's LOAD_FILE() function to SQL UPDATE existing records in a table. I am getting a SQL syntax error I suspect because the file contains, single and double quotes as well as slashes. I have also tried reading the file in binary mode using Perl's binmode into a scalar and using MySQL UPDATE....SET, but that also bombs when the SQL is executed with a syntax error.
I am at a loss, as I know INSERT will also be a pain since the data contains quotes which are needed as field separators. Anyone have any ideas on other approaches I might try?
The actual SQL:
is successful when executed from mysql client, so I know the MySQL requirements are met.UPDATE artists SET page=LOAD_FILE('/tmp/left.txt') where code='aname';
In Perl:
is what bombs. I have checked values of the scalars before SQL execution and they seem fine.UPDATE artistsfull SET page=LOAD_FILE($infile) where code='$code';
Any Spiritual guidance much appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl DBI to MySQL LOAD_FILE
by 1nickt (Canon) on Jan 05, 2017 at 00:45 UTC | |
by Hammer2001 (Novice) on Jan 05, 2017 at 01:36 UTC | |
by 1nickt (Canon) on Jan 05, 2017 at 02:17 UTC | |
by Marshall (Canon) on Jan 05, 2017 at 03:46 UTC | |
|
Re: Perl DBI to MySQL LOAD_FILE
by stevieb (Canon) on Jan 05, 2017 at 00:35 UTC |