--- Ronald J Kimball <[EMAIL PROTECTED]> wrote:
> On Fri, Sep 20, 2002 at 03:44:31PM +0100, Tim Bunce wrote:
>
> > I need to be able to list all the tables in a connected database,
> > then for each table list of columns. I tried to use your table_info(),
> > column_info(), interface but it returns 'DBI::st=HASH(...blah...)'.
> > Trying to output that reference to Data::Dumper returns
> > $VAR1 = bless({}, DBI::st)
>
> As documented, these methods return statement handles, on which you call
> fetch methods to get the actual info.
>
> For example:
>
> my $sth = $dbh->table_info();
>
> while (my(@info) = $sth->fetchrow_array()) {
> print join("\t", @info), "\n";
> }
>
> Ronald
What about column_info()?
#!D:\Perl\Bin\perl.exe
use warnings;
use strict;
use DBI;
use Data::Dumper;
#print DBI->VERSION;
my $dbh = DBI->connect("DBI:mysql:database=avik") or die $DBI::errstr;
my $sth = $dbh->column_info();
while (my(@info) = $sth->fetchrow_array()) {
print join("\t", @info), "\n";
}
$dbh->disconnect;
Gave me this output:
Can't call method "fetchrow_array" on an undefined value at dbi1.pl line 10.
Database handle destroyed without explicit disconnect.
I can't understand what's written in the documentation. The language seems to
be pretty obscure. Please help me to create a script that lists tables and
their columns, maybe I'll figure it out from now on.
Many thanks.
__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com