DBIx::Config is a Perl wrapper around DBI to allow you to simply load database credentials from a file.
SYNOPSIS
Given the like /etc/dbi.yaml, which contains:
MY_DATABASE:
dsn: "dbi:Pg:host=localhost;database=blog"
user: "TheDoctor"
password: "dnoPydoleM"
TraceLevel: 1
The following code would allow you to connect the database:
#!/usr/bin/perl
use warnings;
use strict;
use DBIx::Config;
my $dbh = DBIx::Config->connect( "MY_DATABASE" );
Of course, backwards compatibility is kept, so the following would also work:
#!/usr/bin/perl
use warnings;
use strict;
use DBIx::Config;
my $dbh = DBIx::Config->connect(
"dbi:Pg:host=localhost;database=blog",
"TheDoctor",
"dnoPydoleM",
{
TraceLevel => 1,
},
);
For cases where you may use something like DBIx::Connector, a method is provided that will simply return the connection credentials:
!/usr/bin/perl
use warnings;
use strict;
use DBIx::Connector;
use DBIx::Config;
my $conn = DBIx::Connector->new(DBIx::Config->connect_info("MY_DATABASE"));
Product's homepage
Requirements:
· Perl