perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Vanasco <modperl-l...@2xlp.com>
Subject Re: what is correct way to use mod_perl2, Apache2, and DBI?
Date Mon, 01 May 2006 22:14:07 GMT

On May 1, 2006, at 5:47 PM, Matthew wrote:
> use Apache::DBI;  // this aint working right
what's not working with it?

generally I do this

+ Startup.pl
      Use Apache::DBI

+ DB.pl

my	%_db_config =
(
	dbType 	=> 'postgresql',
	dbi 	=> 'dbi:Pg:dbname=x',
	dbUser 	=> 'x',
	dbPass 	=> 'x',
	dbArgs 	=> { RaiseError => 0, AutoCommit => 1 , TraceLevel => 0 },
);
Apache::DBI->connect_on_init( $_db_config{'dbi'}, $_db_config 
{'dbUser'}, $_db_config{'dbPass'}, $_db_config{'dbArgs'} );
sub dbconnect
{
    $self->_dbconnect_real( \%_db_config )
}

but i write mp handlers, you're just porting

unless someone can chime in quick enough, i'd suggest looking to see  
where the first db connection is being instantiated.  my guess from  
what you've written, is that you're connecting on the server startup  
(maybe in startup.pl somewhere?).  once apache::DBI is loaded, it  
caches all connections - so you'll probably get worse performance  
with every request sharing 1 connection, than with every request  
making/breaking a new request.  you want to make sure that you load  
Apache::DBI in startup.pl, but that you don't make any connections  
until you're in an apache request.


| - - - - - - - - - - - - - - - - - - - -
| RoadSound.com / Indie-Rock.net
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - -





Mime
View raw message