DBIx::Inspector - introspection for DBI

use DBIx::Inspector;

my $dbh = DBI->connect(...) or die;
my $inspector = DBIx::Inspector->new(dbh => $dbh);
my @tables = $inspector->tables;
for my $table (@tables) {
    print "  pk:\n";
    for my $pk ($table->primary_key) {
        print "    ", $pk->name, "\n";
    }
    print "  columns:\n";
    for my $column ($table->columns) {
        print "    ", $column->name, "\n";
    }
}

DBI supports introspection, but it is a too generic and functional. I wrote DBIx::Inspector, it supports OOish introspection.
This is useful to write the dumper like DBIx::Skinny::Schema::Loader.

regards,

Published: 2010-11-27(Sat) 15:15