How to generate list of tables for DB using RoseDB

57 Views Asked by At

I have to list the tables for a given database using RoseDB . I know the mysql command for it :

SHOW TABLES in DB_NAME;

How do I implement this in rose DB ? Pleas help

1

There are 1 best solutions below

0
On

It's not really a Rose::DB-specific question. Simply use the database handle how you would normally in DBI:

package My::DB {

    use Rose::DB;
    our @ISA = qw(Rose::DB);

    My::DB->register_db(
        domain   => 'dev',
        type     => 'main',
        driver   => 'mysql',
        ...
    );

    My::DB->default_domain('dev');
    My::DB->default_type('main');
}

use Carp; 

my $db = My::DB->new();
my $sth = $db->dbh->prepare('SHOW TABLES');

$sth->execute || croak "query failed";

while (my $row = $sth->fetchrow_arrayref) {
    print "$row->[0]\n"; 
}