Catmandu::Importer::DBI - Catmandu module to import data from any DBI source
# From the command line $ catmandu convert DBI --dsn dbi:mysql:foobar --user foo --password bar --query "select * from table" # From Perl code use Catmandu; my %attrs = ( dsn => 'dbi:mysql:foobar' , user => 'foo' , password => 'bar' , query => 'select * from table' ); my $importer = Catmandu->importer('DBI',%attrs); # Optional set extra parameters on the database handle # $importer->dbh->{LongReadLen} = 1024 * 64; $importer->each(sub { my $row_hash = shift; ... });
This Catmandu::Importer can be used to access data stored in a relational database. Given a database handle and a SQL query an export of hits will be exported.
Required. The connection parameters to the database. See DBI for more information.
Examples:
dbi:mysql:foobar <= a local mysql database 'foobar' dbi:Pg:dbname=foobar;host=myserver.org;port=5432 <= a remote PostGres database dbi:SQLite:mydb.sqlite <= a local SQLLite file based database mydb.sqlite dbi:Oracle:host=myserver.org;sid=data01 <= a remote Oracle database
Drivers for each database need to be available on your computer. Install then with:
cpanm DBD::mysql cpanm DBD::Pg cpanm DBD::SQLite cpanm DBD::Oracle
Optional. A user name to connect to the database
Optional. A password for connecting to the database
Required. An SQL query to be executed against the datbase.
Catmandu, Catmandu::Importer , Catmandu::Store::DBI
To install Catmandu::DBI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catmandu::DBI
CPAN shell
perl -MCPAN -e shell install Catmandu::DBI
For more information on module installation, please visit the detailed CPAN module installation guide.