MyDBI -- example sub-class of DBIx::DWIW
MyDBI
DBIx::DWIW
use MyDBI; my $db = MyDBI->Connect(); ## do stuff
See DBIx::DWIW for the functions available to the $db object.
$db
This is the sample MyDBI.pm distributed with DBIx::DWIW.
MyDBI.pm
This package knows many named database configurations (they're like ODBC DSNs in the Windows world, if that helps you at all). They have names like Finance, Games, Homer, etc., with Homer being the default. To access another, use something like:
Finance
Games
Homer
my $db = MyDBI->Connect('Games');
Note that if you use the single argument form of Connect(), which we highly recommend, you are specifying a configuration name, not necessarily a database name. That is, configuration names and database names may not necessarily be related. You might have a database called Homer on two servers, test and production. You might defined a configuration named Homer-test and one called Homer-prod to make things clear. The two may only differ in the host they connect to.
Connect()
Homer-test
Homer-prod
The configuration name internally supplies a host, user, password, and database name. Using these gives us the flexability to move/rename databases, servers, and make other changes without having to update lots of code.
To install DBIx::DWIW, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::DWIW
CPAN shell
perl -MCPAN -e shell install DBIx::DWIW
For more information on module installation, please visit the detailed CPAN module installation guide.