Catman...er::DBI(3pm)

πŸ“¦
version 0.13 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– 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