Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

DBI trace and Apache

by Anonymous Monk
on Sep 14, 2019 at 06:55 UTC ( #11106161=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm redirecting DBI trace to a file from within a CGI script.
The script contains some info but not the sql query.
There has to be something wrong with the environment becuase in other servers I can see the sql output
Any htoughts?

Replies are listed 'Best First'.
Re: DBI trace and Apache
by Corion (Pope) on Sep 14, 2019 at 07:21 UTC

    Maybe it is your version of DBI on that machine?

    You can output that by using

    print "Installed DB driver versions, and DBI version:\n"; DBI->installed_versions;

    This will output something like:

    Perl : 5.028001 (x86_64-linux-gnu-thread-multi) OS : linux (4.9.0) DBI : 1.642 DBD::Sponge : 12.010003 DBD::SQLite : 1.64 DBD::Proxy : install_driver(Proxy) failed: Can't locate RPC/PlC in @INC (you may need to install the RPC::PlClient module) DBD::Mem : 0.001 DBD::Gofer : 0.015327 DBD::File : 0.44 DBD::ExampleP : 12.014311 DBD::DBM : 0.08

    Alternatively, you can hook into the execution of SQL statements and output them yourself (if the version of DBI is recent enough):

    sub dbh_install( $self, $dbh ) { my $previous_handler = $dbh->{HandleError}; $dbh->{Callbacks} = { prepare => sub { my ($dbh, $query, $attrs) = @_; print "Preparing q{$query}\n" }, execute => sub { print "Executing ", shift->{Statement}, "\n"; } }; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11106161]
Approved by marto
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2019-10-14 17:54 GMT
Find Nodes?
    Voting Booth?