It's cool that your program works now. Presumably, since the solution was to put $infile inside single quotes, your SQL is inside double quotes not shown in your OP, as in
I may be wrong about that, but if so, you really should consider using placeholders. As soon as your data value contains an embedded apostrophe your SQL will break. Then you'll find yourself using backslashes, or maybe DBI's quote() ... it's much better practise and allows your code to be much more flexible to use bind values almost always. As I showed above you can even do so with do().$sql = "UPDATE artists SET page=LOAD_FILE('$infile') where code='$code +';";
And if you are working with a list of values to be inserted, as you say, using placeholders will make your process much more efficient since the query can be prepared just once outside the loop. Assuming you had a hash of files keyed by code:
my $sth = $dbh->prepare('UPDATE artists SET page=LOAD_FILE(?) WHERE co +de=?'); for my $code ( keys %hash ) { $sth->execute( $hash{$code}, $code ); }
Hope this helps!
In reply to Re^3: Perl DBI to MySQL LOAD_FILE
by 1nickt
in thread Perl DBI to MySQL LOAD_FILE
by Hammer2001
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |