perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vladimir S. Tikhonjuk" <...@vst.donetsk.ua>
Subject Project config options
Date Sun, 20 Aug 2006 10:18:24 GMT
Hi all!

Here is my little example of how I keep my DBI connection options for
the project.
May be someone have better example for such task ?

1. /usr/local/lib/site_perl/Promtelecom/Config.pm:

============ BEGIN Config.pm ==========

package Promtelecom::Config;

use strict;

%Promtelecom::Config::DBIConnectionOption = (
  database => 'database',
  host => 'host',
  user => 'user',
  password => '123456',
  PrintError => 1,
  RaiseError => 1,
  AutoCommit => 0
);

1;

============ END Config.pm ==========

2. /etc/apache2/modules.d/apache-dbi-startup.pl:

============ BEGIN apache-dbi-startup.pl ==========
$ENV{MOD_PERL} or die "GATEWAY_INTERFACE not Perl!";
use Apache::DBI;
use Promtelecom::Config;
use strict;

$Apache::DBI::DEBUG = 1;

Apache::DBI->connect_on_init(
 
'dbi:Pg(PrintError=>'.$Promtelecom::Config::DBIConnectionOption{PrintError}.',RaiseError=>'.$Promtelecom::Config::DBIConnectionOption{RaiseError}.',AutoCommit
=>'.$Promtelecom::Config::DBIConnectionOption{AutoCommit}.'):dbname=web_promtelecom;host=localhost',
  $Promtelecom::Config::DBIConnectionOption{user},
  $Promtelecom::Config::DBIConnectionOption{password}
);

1;
============ END apache-dbi-startup.pl ==========

3. /etc/apache2/httpd.conf:

============ BEGIN PART httpd.conf ==========
PerlRequire "/etc/apache2/modules.d/apache-dbi-startup.pl"
============ END PART httpd.conf ==========

So, when I have to get database connection into some handle, I use
%Promtelecom::Config::DBIConnectionOption hash for connection options.


Best regards,
Vladimir S. Tikhonjuk

Mime
View raw message