| Catmandu::Importer::DBI(3pm) | User Contributed Perl Documentation | Catmandu::Importer::DBI(3pm) |
Catmandu::Importer::DBI - Catmandu module to import data from any DBI source
Text columns are assumed to be utf-8.
# 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.
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
Catmandu, Catmandu::Importer , Catmandu::Store::DBI
| 2023-07-07 | perl v5.36.0 |