Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by roboticus (Chancellor)
on Mar 17, 2020 at 15:33 UTC ( [id://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

perlygapes:

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).

...roboticus

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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-23 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found