Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Class::DBI connect info from file?

by jest (Pilgrim)
on Jan 21, 2004 at 22:15 UTC ( #323041=note: print w/replies, xml ) Need Help??


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

DB_NAME = library DB_HOST = localhost DB_USER = username DB_PASS = password
Then, in my base DBI package, I have:
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://323041]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2022-01-18 07:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (52 votes). Check out past polls.

    Notices?