Anyone got any advice or pointers on using Pg, mod_perl and persistant DB connections with apache

From: "Ken Wills" <gfccall(at)mailbag(dot)com>
To: <pgsql-interfaces(at)hub(dot)org>
Subject: Anyone got any advice or pointers on using Pg, mod_perl and persistant DB connections with apache
Date: 1998-10-23 18:00:32
Message-ID: 008601bdfeaf$08389620$031f46c6@kpw.gfc.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

I'm using Apache 1.3.1 with mod_perl (latest). I want to open a single persistant db connection
to postgres and feed all the info to and from apache from this. Currently i'm doing this :

my $conn = Pg::connectdb("dbname=$db_name host=$db_host user=$db_user password=$db_password");
my $query = new CGI;
...etc..
..do the query...
..etc..

and it works fine, except for the fact that it starts a new postgres process to do the query, but never
seems
to close it. (How do you close them? I've tried using PQfinish...)I understand that this method is supposed
to do that. I've tried globaly declaring a connection in apache's startup.perl script, but have had no
success with that - if I try something like :

use CGI;
use Pg;
use Shell qw(cat);

if ($dbh->status == PGRES_CONNECTION_BAD) {
$dbh = Pg::connectdb("dbname=$db_name host=$db_host user=$db_user password=$db_password");
}

at the top of each script, it complains that I have to 'use' Pg before I can do the $dbh->status check.

I have read all the docs, manpages etc for pointers on how to do this, with no real mention of anything.
mod_perl has a
brief pointer on how to do it with DBI. Would I be better off using DBI.

Any help/pointers very appreciated.

Thanks

Ken

Ken Wills
GFC Call Center
Email: gfchelp(at)gflesch(dot)com
Phone: 1-888-4325556
Fax: 1-608-2222432

Browse pgsql-interfaces by date

  From Date Subject
Next Message Peter Garner 1998-10-25 12:34:14 aborted transactions
Previous Message Oleg Amiton 1998-10-23 16:55:42 Ecpg