Re: Connect without specifying a database?

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: "lists(at)mgreg(dot)com" <lists(at)mgreg(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Connect without specifying a database?
Date: 2009-04-11 15:39:55
Message-ID: 49E0B9CB.7090408@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/04/2009 16:30, lists(at)mgreg(dot)com wrote:

> Quick question: Does PGSQL provide a mechanism by which to connect to
> the server without specifying a database? I saw a thread back in 2005
> that said "no"
> (http://archives.postgresql.org//pgsql-interfaces/2005-02/msg00031.php),
> but I was curious as to whether that's changed. Basically I need to be
> able to dynamically determine what databases exist etc before performing
> certain actions in my application.

The answer is still "no". :-)

The usual thing it to connect to the "postgres" database (or to
"template1" in older versions of PG), and then you can issue queries to
see what's there. You're pretty much guaranteed that one of those
databases will exist (they're created by initdb), unless whoever
installed the server did something strange.

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message lists@mgreg.com 2009-04-11 15:49:25 Re: Connect without specifying a database?
Previous Message Sam Mason 2009-04-11 15:38:53 Re: Connect without specifying a database?