Skip Menu |

This queue is for tickets about the DBD-mysql CPAN distribution.

Report information
The Basics
Id: 25569
Status: resolved
Priority: 0/
Queue: DBD-mysql

Owner: Nobody in particular
Requestors: pierrick_trash [...]

Bug Information
Severity: (no value)
Broken in: 4.003
Fixed in: 4.001

Subject: table_info returns no table
Download (untitled) / with headers
text/plain 1.2k
$ 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";
Download (untitled) / with headers
text/plain 298b
Hi! This actually works per the DBI spec-- the perldoc for DBI: "If the value of $schema is ā€™%ā€™ and $catalog and $table are empty strings, the result set contains a list of schema names." So, if you want a list of all schemas and their tables, simply leave the schema name blank.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to