Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^3: DBD::Pg - $sth->execute($csv_var) ERROR

by roboticus (Chancellor)
on Mar 17, 2020 at 15:33 UTC ( #11114391=note: print w/replies, xml ) Need Help??

in reply to Re^2: DBD::Pg - $sth->execute($csv_var) ERROR
in thread DBD::Pg - $sth->execute($csv_var) ERROR


I'd definitely try the commit to see if that does the trick, but I'd also check to see if the statement had an error or not. If it *does*, then you can use the AutoCommit flag on the connect statement to avoid having to do a commit after every operation (though you might prefer the safety of handling commit yourself).

Since you could be getting an error from Pg, you'll want to check the error status of any command. An insert will fail if you violate a constraint on the table for example. So I tell DBI (on the connect statement) to check every statement and raise errors (using RaiseError and PrintError).


When your only tool is a hammer, all problems look like your thumb.

  • Comment on Re^3: DBD::Pg - $sth->execute($csv_var) ERROR

Replies are listed 'Best First'.
Re^4: DBD::Pg - $sth->execute($csv_var) ERROR
by perlygapes (Sexton) on Mar 18, 2020 at 03:54 UTC

    Hmmm...that's excellent exegesis.

    Whence I had thought I besought for errors to be caught then taught, I had:

    my $dbh = DBI->connect($DSN, $userid, $sesame, { AutoCommit => 0, RaiseError => 1, PrintError => 0 }) or die "Connection failed!\n" . $DBI::errstr;

    Hence I shall beseech for errors to be bleached and for Pg to teach me with:

    my $dbh = DBI->connect($DSN, $userid, $sesame, { AutoCommit => 1, RaiseError => 1, PrintError => 1 }) or die "Connection failed!\n" . $DBI::errstr;

    May thy code be blessed by the Profit of thy scripts.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11114391]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2020-10-25 20:59 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (249 votes). Check out past polls.