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

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

by perlygapes (Sexton)
on Mar 16, 2020 at 03:53 UTC ( [id://11114322]=note: print w/replies, xml ) Need Help??


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

Well, OK.
Your Pastoral Guidance has borne fruit and blessed my scriptural offerings.
I see smoke rising from the alter as I turn the STHandle on the door to data salvation.
But lo, are there wolves among these sheep?
Have I put my trust in a False Religion?

I receive no admonitions from Pg, yet upon SELECT supplications, it is as if my offerings are remembered no more. I wonder, are my indulgences counted as nothing more than lip service?

I accept, of course, the answer to this question may fall outside of the remit of the Perl Priesthood. Perhaps this is a question for the PG Priesthood?

Can Perl Priests intercede with Pg?
Doth thou knowest how to solicit exegetical corrective advice from Pg?

Must I make an open confession of faith with:
$sth->commit();
?

If I say $sth->errstr(); will Pg enlighten me?

Obligations

Replies are listed 'Best First'.
Re^3: DBD::Pg - $sth->execute($csv_var) ERROR
by roboticus (Chancellor) on Mar 17, 2020 at 15:33 UTC

    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.

      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://11114322]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-25 22:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found