dbdpg icon indicating copy to clipboard operation
dbdpg copied to clipboard

How to pass multiple hosts and connection parameter target_session_attrs in connection string.

Open nicolasfranck opened this issue 3 years ago • 1 comments

According to the documentation of libpq it is possible to specify multiple hosts in the connection string. This syntax is used to connect to a cluster with master and standby nodes. Parameter target_session_attrs determines what node will be chosen by libpg.

It is however not clear how one should specify this in the DBI syntax. This host=host1,host2 doesn't work for sure. Is this supported?

nicolasfranck avatar Jan 24 '22 13:01 nicolasfranck

Works for me: can you show the complete error? Here's a local example:

$ perl -MDBD::Pg -e 'use DBI; my $dbh = DBI->connect("dbi:Pg:host=foo,bar,baz","","",{PrintError=>1})'
DBI connect('host=foo,bar,baz','',...) failed: could not translate host name "foo" to address: No address associated with hostname
could not translate host name "bar" to address: No address associated with hostname
could not translate host name "baz" to address: Name or service not known at -e line 1.

$ perl -MDBD::Pg -e 'use DBI; my $dbh = DBI->connect("dbi:Pg:host=foo,bar,baz,localhost","","",{PrintError=>1})'
$

turnstep avatar Mar 01 '22 12:03 turnstep

Closing

turnstep avatar Aug 16 '23 23:08 turnstep