in reply to Skip problematic lines while populating database
The ideal first step would be to use DBI placeholders instead of creating a string-SQL statement. The second step would be to use Text::CSV_XS for parsing your delimited input file.
my $sth_insert = $dbi->prepare(<<'SQL'); INSERT INTO biochemical VALUES (?,?,?,?,?,?,?,?,?,?,...,?) SQL for my $row (@rows) { $sth_insert->execute( @$row ); };
By using DBI placeholders, you don't need to care about special characters like double quotes in strings.
Then, when inserting, switch off the RaiseError flag:
local $sth_insert->{RaiseError} = 0; for my $row (@rows) { $sth_insert->execute( @$row ); };
That way, the script does not die anymore on insert errors.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Skip problematic lines while populating database
by Tux (Canon) on Aug 17, 2020 at 15:39 UTC | |
|
Re^2: Skip problematic lines while populating database
by AnomalousMonk (Archbishop) on Aug 17, 2020 at 15:55 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |