Re: Multiple logical databases

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Mark Woodward <pgsql(at)mohawksoft(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Multiple logical databases
Date: 2006-02-18 21:38:11
Message-ID: 20060218213811.GI20716@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Fri, Feb 03, 2006 at 08:05:48AM -0500, Mark Woodward wrote:
> Like I said, in this thread of posts, yes there are ways of doing this,
> and I've been doing it for years. It is just one of the rough eges that I
> think could be smoother.
>
> (in php)
> pg_connect("dbname=geo host=dbserver");
>
> Could connect and query the dbserver, if the db is not on it, connect to a
> database of known servers, find geo, and use that information to connect.
> It sounds like a simple thing, for sure, but to be useful, there needs to
> be buy in from the group otherwise it is just some esoteric hack.

It turns out what you like actually exists, lookup the "service"
parameter in the connectdb string. It will read the values for the
server, port, etc from a pg_service.conf file.

There is an example in the tree but it looks something like the following:

[servicename]
dbname=blah
user=blah
pass=blah

So all you need to specify is "service=servicename" and it will grab
the parameters. This allows you to change the connection without
changeing the code.

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> 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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2006-02-18 22:01:06 Re: Pgfoundry and gborg: shut one down
Previous Message Martijn van Oosterhout 2006-02-18 20:40:04 Re: Config file for psql

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2006-02-19 00:05:02 Re: add additional options to CREATE TABLE ... AS
Previous Message Neil Conway 2006-02-18 20:53:14 Re: pgcrypto: fix memory leak in openssl.c