MooseX::Role::DBIx::Connector - give your Moose class DBIx::Connector powers
package MyClass; use Moose; with 'MooseX::Role::DBIx::Connector'; package main; my $c = MyClass->new( db_dsn => 'dbi:Pg:dbname=foo;host=bar', db_user => 'mikey', db_password => 'seekrit', db_attrs => { Foo => 'Bar' }, ); $c->db_conn->dbh->selectall_arrayref( ... ); $c->db_conn->txn( fixup => sub { ... } ); ### more advanced usage package BigClass; use Moose; with 'MooseX::Role::DBIx::Connector' => { connection_name => 'itchy' }; with 'MooseX::Role::DBIx::Connector' => { connection_name => 'scratchy' }; package main; my $c = BigClass->new( itchy_dsn => 'dbi:Pg:dbname=foo;host=bar', itchy_user => 'mikey', itchy_password => 'seekrit', scratchy_dsn => 'dbi:SQLite:dbname=somefile', ); $c->itchy_conn->dbh->selectall_arrayref( ... ); $c->scratchy_conn->txn( fixup => sub { ... } );
Generic parameterized Moose role to give your class accessors to manage one or more DBIx::Connector connections.
Name for this connection, which is the prefix for all the generated accessors. Default 'db', which means that you get the accessors db_dsn, db_user, db_password, db_attrs, and db_conn.
db_dsn
db_user
db_password
db_attrs
db_conn
Plaintext description of this connection. Only used in generating documentation for each of the generated accessors.
documentation
Hashref of additional options to pass to the generated accessors, e.g.
package MyClass; use Moose; with 'MooseX::Role::DBIx::Connector' => { connection_name => 'itchy', accessor_options => { 'itchy_dsn' => [ traits => ['GetOpt'], ], 'itchy_user' => [ default => 'minnie_the_moocher' ], } };
Get a DBIx::Connector connection object for the given connection info.
DBI DSN for your connection. Required.
Username for the connection.
Password for the connection.
Hashref of DBI attributes for the connection. Passed to DBIx::Connector, which passes them to DBI's connect()
Robert Buels, <rmb32@cornell.edu>
To install MooseX::Role::DBIx::Connector, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Role::DBIx::Connector
CPAN shell
perl -MCPAN -e shell install MooseX::Role::DBIx::Connector
For more information on module installation, please visit the detailed CPAN module installation guide.