Subject: | table_info returns no table |
$ perl -e 'use DBI; DBI->installed_versions()'
Perl : 5.008007 (i486-linux-gnu-thread-multi)
OS : linux (2.6.10)
DBI : 1.52
DBD::mysql : 4.003
Show quoted text
mysql> select version();
+-------------------------------+
| version() |
+-------------------------------+
| 5.0.22-Debian_0ubuntu6.06-log |
+-------------------------------+
Using DBD::mysql 4.003, table_info returns no table in the following
script. 3.0008 or 4.001 works perfectly.
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect(
sprintf(
'DBI:mysql:database=%s;host=%s;port=%s',
'talend',
'localhost',
'3306',
),
'root',
'conway',
{
}
)
or die "can't connect to database";
my $sth;
my $query;
# We need the table list to know if drop or "create if not exists" is
# relevant
my $schema = '%';
my $catalog = undef;
my $tabsth = $dbh->table_info($catalog, $schema);
my @tables = ();
while (my $entity = $tabsth->fetchrow_hashref()) {
if ($entity->{TABLE_TYPE} eq 'TABLE') {
push @tables, lc $entity->{TABLE_NAME};
}
}
print "===\n";
print "existing tables:\n";
print join("\n", map {" - ".$_} @tables), "\n";
print "===\n";