"show databases" via DBD::mysql
Michael Stillwell
mjs at beebo.org
Thu Jan 12 16:39:51 GMT 2006
On 13 Jan 2006, at 03:03, Paul Makepeace wrote:
> I've tried a bunch of things with $dbh->table_info and none seem to be
> returning anything about the catalogs/schema, just tables of the
> selecting dbname. Anyone?
Have never used table_info(), but if it helps any, here's some code
that uses DESCRIBE to determine column names and types:
my $dbi = DBI->connect(...);
my $schema = do {
my $sth = $dbi->prepare(qq{DESCRIBE $table});
$sth->execute;
my %h = map { $_->{Field} => $_->{Type} }
@{$sth->fetchall_arrayref({})};
\%h;
};
# $schema->{COLUMN_NAME} = "TYPE";
--M.
--
http://beebo.org
+44 78 2118 9049
More information about the london.pm
mailing list