"show databases" via DBD::mysql

Chris Benson chrisb at jesmond.demon.co.uk
Thu Jan 12 20:34:37 GMT 2006


On Thu, Jan 12, 2006 at 04:03:39PM +0000, 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?

Erm, I think there's an impedance mismatch between DBI and MySQL here.
 
AIUI there are only DBs and tables in MySQL.  Are you after all the
tables in a database or all the available databases?

> If I omit dbname=foo from the DSN it complains about a database not
> being selected.

If you want the databases that are available,

         @data_sources = DBI->data_sources($driver_name, \%attr);

does it for me: 
$ perl -MDBI -le 'print "@{ [ DBI->data_sources(q(mysql)) ] }"'
DBI:mysql:home DBI:mysql:mysql DBI:mysql:test
 
> PS for those that don't read subject lines assiduously, this is about
>    MySQL not any other, very possibly compliant, DB.

:-)
-- 
Chris Benson


More information about the london.pm mailing list