Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

(jeffa) Re: How to report call stack for DBI queries

by jeffa (Bishop)
on Apr 17, 2003 at 18:07 UTC ( [id://251277]=note: print w/replies, xml ) Need Help??


in reply to How to report call stack for DBI queries

Maybe jdporter's Hook::WrapSub would be useful here? Something like:
use strict; use warnings; use DBI; use Data::Dumper; use Hook::WrapSub qw( wrap_subs unwrap_subs ); wrap_subs \&log_prepare, 'DBI::db::prepare'; wrap_subs \&log_execute, 'DBI::st::execute'; my $dbh = DBI->connect( qw(DBI:driver:database:host user pass), {RaiseError=>1} ); my $sth = $dbh->prepare('select foo,bar from qux'); $sth->execute(); $sth->finish(); $dbh->disconnect; unwrap_subs qw(DBI::db::prepare DBI::st::execute); # just announce we were called and dump our args sub log_prepare { print "prepare called:\n", Dumper \@_; } sub log_execute { print "execute called:\n", Dumper \@_; }

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: How to report call stack for DBI queries
by mp (Deacon) on Apr 17, 2003 at 18:26 UTC
    Jeffa, thank you. This is exactly what I needed.

    I am planning to use this to create a log that identifies where database queries are being prepared/executed after having used DBI::ProfileDumper to profile the queries in a mod_perl application.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-26 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found