sql icon indicating copy to clipboard operation
sql copied to clipboard

Multiple hosts and ports in DSN string

Open roquie opened this issue 5 years ago • 1 comments

Hi!

I think, supports of multiple host components is an important feature. Because database may be connected to master and slaves servers.

https://www.postgresql.org/docs/12/libpq-connect.html#LIBPQ-CONNSTRING

It is possible to specify multiple host components, each with an optional port component, in a single URI. A URI of the form postgresql://host1:port1,host2:port2,host3:port3/ is equivalent to a connection string of the form host=host1,host2,host3 port=port1,port2,port3. Each host will be tried in turn until a connection is successfully established.

In future I'll maybe create a Pull Request, but for now issue should be created as reminder :)

roquie avatar May 19 '20 08:05 roquie

You can already achieve something similar if you use DNS and provide multiple IPs there, as Amp will automatically try the other IPs if the connection to the first IP fails.

kelunik avatar May 19 '20 19:05 kelunik