Thread: PGBouncer Connection Using Perl DBI
Hello , Could you please tell me some one ,how to do connection PGBouncer using Perl DBI module ? Thanks Prashant |
On 08/27/2012 09:51 AM, Prashant Bharucha wrote: > Hello , > Could you please tell me some one ,how to do connection PGBouncer using > Perl DBI module ? Exactly the same way you connect to PostgreSQL normally: specify a hostname, port and database name. Instead of specifying those for the PostgreSQL server, specify the details for the PgBouncer server that's proxying for PostgreSQL. -- Craig Ringer
Prashant --
I haven't tried this -- we don't use DBI currently -- but wouldn't it get treated as any other connection if you point the DBI connection to the pgbouncer host / port / database ? pgbouncer should redirect the query according the rules in its .ini file.
HTH,
Greg Williamson
From: Prashant Bharucha <prashantbharucha@yahoo.ca>
To: pgsql-general@postgresql.org
Sent: Sunday, August 26, 2012 6:51 PM
Subject: [GENERAL] PGBouncer Connection Using Perl DBI
Hello ,Could you please tell me some one ,how to do connection PGBouncer using Perl DBI module ?ThanksPrashant
Hi Craig I got connection to pgbouncer,but how do i pass actual database parameter to connect . I attached my perl script and getting error : prepared statement "dbdpg_p27841_1" Thanks my $PGDBNAME = 'test'; my $PGDBSERVER = '172.16.40.19'; my $PGDBUSER = 'postgres'; my $PGDBPASSWD = 'postgres'; my $PORT = '6432'; &main (); sub main { my $dbh = DBI->connect("dbi:Pg:dbname=$PGDBNAME;host=$PGDBSERVER;port=$PORT;",$PGDBUSER,$PGDBPASSWD,{ RaiseError => 1, AutoCommit => 1, }); print ref($dbh); my $sql = qq { select count(*) from a }; my $cursor = $dbh->prepare($sql); $cursor->execute() ; my $raw = $cursor->fetchrow_hashref(); } -- View this message in context: http://postgresql.1045698.n5.nabble.com/PGBouncer-Connection-Using-Perl-DBI-tp5721311p5721576.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
On Tue, Aug 28, 2012 at 8:33 AM, prashantbharucha <prashantbharucha@yahoo.ca> wrote: > Hi Craig > > I got connection to pgbouncer,but how do i pass actual database parameter > to connect . > > I attached my perl script and getting error : prepared statement > "dbdpg_p27841_1" That doesn't look like a complete error message. Is there more to it? What line number is it coming from? You can't use prepared statements if you are using statement level pooling. Maybe that is the issue. Cheers, Jeff