Apache::Status plugin to show all DBI connections and statements
am 21.03.2007 13:59:12 von Tim.BunceI needed an Apache::Status plugin to show all DBI connections and statements.
I couldn't see one so I wrote one...
It uses the fact that DBI (>= 1.49) now keeps weak refs to child handles,
so it's possible to drill-down through every DBI handle that exists.
I've appended a sample of the output. (It's copied from the web page so
has lost the bolding and dimming that the real output uses in places.)
Would anyone find this useful?
Does anyone want to turn it into a CPAN distribution and maintain it?
Tim.
------------------------------------------------------------ ----------------------------------------------
DBI 1.55 - Drivers, Connections and Statements
4 drivers loaded: DBM, Sponge, ExampleP, Gofer
------------------------------------------------------------ ----------------------------------------------
DBD::DBM version 0.03, 2 dbh (2 cached, 2 active) DBI::dr=HASH(0x18f3010)
DSN "dbm_type=SDBM_File;lockfile=0" DBI::db=HASH(0x193e374)
Attributes: Active, Executed, RaiseError, ShowErrorStatement, AutoCommit
Attributes: ErrCount=1, TraceLevel=0, FetchHashKeyName='NAME', LongReadLen=80, Username=undef
Statement: SELECT dKey, dVal FROM fruit
DSN "dbm_type=SDBM_File;mldbm=;lockfile=0;f_dir=/Users/timbo/dbi /trunk/test_output" DBI::db=HASH(0x192256c)
Attributes: Active, Executed, RaiseError, ShowErrorStatement, AutoCommit
Attributes: ErrCount=0, TraceLevel=0, FetchHashKeyName='NAME', LongReadLen=80, Username=undef
Statement: DELETE FROM SDBM_File_fruit WHERE dVal='to delete'
------------------------------------------------------------ ----------------------------------------------
DBD::ExampleP version 12.009153, 5 dbh (5 cached, 5 active) DBI::dr=HASH(0x18a6bc4)
DSN "." DBI::db=HASH(0x18f0b18)
Attributes: Active, RaiseError, AutoCommit
Attributes: ErrCount=0, TraceLevel=0, FetchHashKeyName='NAME', LongReadLen=80, Username=undef
DSN "" DBI::db=HASH(0x18ef52c)
Attributes: Active, Executed, RaiseError, AutoCommit
Attributes: ErrCount=3, TraceLevel=0, FetchHashKeyName='NAME', LongReadLen=80, Username=''
Statement: SELECT name FROM t
sth: 1 (1 cached, 0 active)
sth DBI::st=HASH(0x195ec00)
Attributes: Executed, RaiseError
Attributes: ErrCount=0, TraceLevel=0, FetchHashKeyName='NAME', LongReadLen=80
Statement: select name from ?
ParamValues: 1='.'
Attributes: NUM_OF_PARAMS=1, NUM_OF_FIELDS=1, CursorName=undef
Rows: 40
------------------------------------------------------------ ----------------------------------------------