Re: Get a list of databases?

From: Kevin Hunter <hunteke(at)earlham(dot)edu>
To: Neil Aggarwal <neil(at)JAMMConsulting(dot)com>
Cc: PostgresQL Novice List <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Get a list of databases?
Date: 2007-02-27 14:53:54
Message-ID: 45E44602.801@earlham.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 27 Feb 2007 at 3:12p +0900, Joseph Speigle wrote:
>> My code needs to be able to allow the user to select which
>> database to connect to.
>>
>> Is there a programmatic way to get a list of the databases
>> managed by a pgsql server?
> you mean like 'psql >\l' ?
> try
> select datname from pg_database;

I found that setting the ECHO_HIDDEN psql runtime variable to be fairly
informative with something like this. It basically explains exactly the
queries it runs against the DB to do anything. Either from the
commandline or in your .psqlrc file:

\set ECHO_HIDDEN TRUE

Then do something mundane like '\d'.

HTH,

Kevin

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Brian Hurt 2007-02-27 15:26:10 Revoking the right to create (non-temporary) tables?
Previous Message joseph speigle 2007-02-27 06:12:55 Re: Get a list of databases?