.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Catmandu::Importer::DBI 3pm" .TH Catmandu::Importer::DBI 3pm 2024-03-24 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Catmandu::Importer::DBI \- Catmandu module to import data from any DBI source .SH LIMITATIONS .IX Header "LIMITATIONS" Text columns are assumed to be utf\-8. .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& # 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 => \*(Aqdbi:mysql:foobar\*(Aq , \& user => \*(Aqfoo\*(Aq , \& password => \*(Aqbar\*(Aq , \& query => \*(Aqselect * from table\*(Aq \& ); \& \& my $importer = Catmandu\->importer(\*(AqDBI\*(Aq,%attrs); \& \& # Optional set extra parameters on the database handle \& # $importer\->dbh\->{LongReadLen} = 1024 * 64; \& \& $importer\->each(sub { \& my $row_hash = shift; \& ... \& }); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" 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. .SH CONFIGURATION .IX Header "CONFIGURATION" .IP dsn 4 .IX Item "dsn" Required. The connection parameters to the database. See DBI for more information. .Sp Examples: .Sp .Vb 4 \& dbi:mysql:foobar <= a local mysql database \*(Aqfoobar\*(Aq \& 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 .Ve .Sp Drivers for each database need to be available on your computer. Install then with: .Sp .Vb 4 \& cpanm DBD::mysql \& cpanm DBD::Pg \& cpanm DBD::SQLite \& cpanm DBD::Oracle .Ve .IP user 4 .IX Item "user" Optional. A user name to connect to the database .IP password 4 .IX Item "password" Optional. A password for connecting to the database .IP query 4 .IX Item "query" Required. An SQL query to be executed against the datbase. .SH "SEE ALSO" .IX Header "SEE ALSO" Catmandu, Catmandu::Importer , Catmandu::Store::DBI