Subject: Config file for psql

From: Martijn van Oosterhout <[email-masked]>
Date: Sat, 18 Feb 2006 19:52:22 +0100

Hi,

A little while ago there was someone asking for tools to make it easier
to connect to multiple servers. It occured to me that it might be
useful to have a config file the way ssh does it:

Host production
  ServerName  db1
  DBName      main
  Username    blah
  Password    blah
  UseSSL      yes

Host test
  ServerName db2
  ServerPort 5434
  DBName     main
  Username   blah
  Password   blah

Host *
  Username    default

So when you type "psql test" it fills in the server name, port,
database, username and password for you. For hosts not listed, it gives
a default username "default". It's really just a variation on the
.netrc file.

Thoughts?
-- 
Martijn van Oosterhout   <[email-masked]>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

---

From: Peter Eisentraut <[email-masked]>
Date: Sat, 18 Feb 2006 20:12:29 +0100

Martijn van Oosterhout wrote:
> A little while ago there was someone asking for tools to make it
> easier to connect to multiple servers. It occured to me that it might
> be useful to have a config file the way ssh does it:

That looks suspiciously like the service facility that we already have.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/

---

From: Michael Fuhr <[email-masked]>
Date: Sat, 18 Feb 2006 12:19:39 -0700

> useful to have a config file the way ssh does it:

Something like pg_service.conf?  Hardly anybody ever mentions it
even though the libpq documentation refers to it; I wonder how many
people even know it exists.

http://www.postgresql.org/docs/8.1/interactive/libpq.html#LIBPQ-CONNECT
http://www.postgresql.org/docs/8.1/interactive/libpq-envars.html

-- 
Michael Fuhr

---

From: Andrew Dunstan <[email-masked]>
Date: Sat, 18 Feb 2006 14:37:44 -0500

>http://www.postgresql.org/docs/8.1/interactive/libpq-envars.html

This needs a LOT more prominence. We probably need to refer to these 
things on the manual pages for each of the libpq clients we have. 
Haven't we learned that lesson from .pgpass ? The number of people who 
read the libpq docs is probably vanishingly small.

cheers

andrew

---

From: Tom Lane <[email-masked]>
Date: Sat, 18 Feb 2006 14:49:08 -0500

> read the libpq docs is probably vanishingly small.

Perhaps we should make a concerted effort to split the libpq docs into a
section "for programmers" vs one "for users", the latter part covering
the libpq behavior that is interesting to users of a libpq-based app.
.pgpass, pg_service, the environment vars, SSL behavior, maybe some
other things belong in the "for users" part.

I think only the environment-vars page is currently linked from the
client-apps reference pages, but if we did this we could link to the
entire for-users section and be done with it.

			regards, tom lane

---

From: Martijn van Oosterhout <[email-masked]>
Date: Sat, 18 Feb 2006 21:40:04 +0100

> people even know it exists.

I'd say not many? If you search the mail archives for "pg_service.conf"
in the last two years, there's only 15 matches and even then it's only
ever mentioned on -hackers or -patches.

For example, nobody brought it up that last thread about connecting to
multiple servers, even though it would have been the perfect solution.

I certainly never heard of it and I've been using postgres and been on
-general for several years.

Have a nice day,

---

From: "Jim C. Nasby" <[email-masked]>
Date: Sun, 19 Feb 2006 11:25:17 -0600

> other things belong in the "for users" part.

+1. Is there a docs TODO?
-- 
Jim C. Nasby, Sr. Engineering Consultant      [email-masked]
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

---

From: Bruce Momjian <[email-masked]>
Date: Tue, 28 Feb 2006 14:48:31 -0500 (EST)

> +1. Is there a docs TODO?

Added to TODO:

	* Split out libpq pgpass and environment documentation sections
	  to make it easier for non-developers to find

Looking at the existing manual, how do we do this?  Do we make separate 
libpq-programming and a libpq-runtime sections?

-- 
  Bruce Momjian   http://candle.pha.pa.us
  SRA OSS, Inc.   http://www.sraoss.com

  + If your life is a hard drive, Christ can be your backup. +