Hi Friends, I am using mod_perl 2. I question about database connections. I use the Pg module to connect to the backend. Could you tell me that this is not a good idea and I should have used Apache::DBI? When using Pg I run into such problems as when the connection reaches the limit, no more connection can be made. This can be seen on the server that host the postgres server ps -ef | grep postgres will show all the idle postgres processes. To overcome this problem I simply did this in my perl script #!/usr/bin/perl -w use Apache::Request; use Pg; # here I am using the same username and password for all of my # scripts my $dbuser="dbreader"; my $passwd="a_secret_str"; our $pgdb; if (!$pgdb) { $pgdb = Pg::connectdb("host=localhost dbname=$mydb user=$dbuser password=$passwd"); } This seems to work, which means that the number of idle postgres processes on the server does not accumulate to the point that no more connection can be made. I am not sure this solution is to good to be "true". Am I doing the right thing? If I am using the same username and password for all of my scripts on the http server, will this cause problems? Apache::DBI seems to take care of all of my problems. Thanks. Kemin |
- postgres Database Pg module Kemin Zhou
- Re: postgres Database Pg module Perrin Harkins