Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print out all handle attributes of DBI in Perl

Tags:

perl

dbi

To make debugging a bit easier, I want to print out all the keys and values of all handle attributes in DBI.

I tried:

use DBI;
use Data::Dumper;

my $db = DBI->connect(etc);
print Dumper($db);

But I only see "bless {}, 'DBI::db'" Is there a method in DBI itself or a variable I can print with Dumper(), that will print info on the internals of DBI?

like image 231
Jeroen Lodewijks Avatar asked Dec 05 '25 13:12

Jeroen Lodewijks


1 Answers

The DBI docs mention in passing...

A DBI handle is a reference to a tied hash. A tied hash has an inner hash that actually holds the contents.

You can get at this internal attribute hash with tied.

print Dumper tied %$dbh;
like image 198
Schwern Avatar answered Dec 07 '25 14:12

Schwern



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!