in reply to Class::DBI connect info from file?
I keep my connection info in a config file, so I'll have something like library.site.conf that includes
Then, in my base DBI package, I have:DB_NAME = library DB_HOST = localhost DB_USER = username DB_PASS = password
package MyDatabase::DBI; use base qw(Class::DBI::mysql); my %config; use Config::General; my $conf = new Config::General( -ConfigFile => '/usr/local/configfiles/library.site.conf', -InterPolateVars => 1 ); %config = $conf->getall; my $dsn = "DBI:mysql:host=$config{DB_HOST};database=$config{DB_NAME}"; my $db_user = $config{DB_USER}; my $db_pass = $config{DB_PASS}; __PACKAGE__->set_db('Main', $dsn, $db_user, $db_pass); # etc.
There are a ton of similar ways to do this.
|
|---|