Catman...er::DBI(3pm)
π Catman...er::DBI(3pm) π
okay bestie, gather round, because this is the page for Catmandu::Importer::DBI β a User Contributed Perl Documentation joint, sitting pretty in section 3pm. It's the Catmandu module that lets you pull data out of literally any DBI source. no cap. π«Ά
β¨ NAME β¨
Catmandu::Importer::DBI β the Catmandu module that imports data from any DBI source. yes, any. she's flexible like that. π
π§ LIMITATIONS π§
Text columns are assumed to be utf-8. that's the whole limitation, that's the vibe. π¦
πΈ SYNOPSIS πΈ
okay so first, from the command line, she's giving one-liner:
# From the command line
$ catmandu convert DBI --dsn dbi:mysql:foobar --user foo --password bar --query "select * from table"
and then from Perl code, where the real main character energy lives:
# 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;
...
});
see that commented-out LongReadLen line? that's your optional little moment to set extra parameters on the database handle, iykyk. π₯
π DESCRIPTION π
So. This Catmandu::Importer is the one you call when your data is chillin' in a relational database and you need it out. Give her a database handle and a SQL query, and an export of hits will be exported. that's the whole deal, and honestly? she ate. π
π CONFIGURATION π
β dsn
Required. The connection parameters to the database. See DBI for more information. (yes bestie, go read DBI, she's the blueprint.)
Examples, and I need you to look at all of these:
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 them with:
cpanm DBD::mysql
cpanm DBD::Pg
cpanm DBD::SQLite
cpanm DBD::Oracle
no driver, no connection. the vibes will not carry you here, bestie. π
π user
Optional. A user name to connect to the database. optional means optional, but she's there if you need her. π
π password
Optional. A password for connecting to the database. keep it secret, keep it safe. π€«
π¦ query
Required. An SQL query to be executed against the datbase. (yes, that's how the original spells it β "datbase" β we don't fix her, we love her.) π
π SEE ALSO π
- Catmandu
- Catmandu::Importer
- Catmandu::Store::DBI
go read them, they're all iconic in their own way. periodt. β¨
and that's the page, bestie!! this one's perl v5.38.2, dated 2024-03-24, brought to you by the fine folks behind User Contributed Perl Documentation. mwah, go query something. ππ
π«Ά
π¦ where this page comes from
- debian trixie: libcatmandu-dbi-perl 0.13-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcatmandu-dbi-perl 0.13-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-dbi-perl 0.13-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms