Re: list of databases in C ? libpq ? - Mailing list pgsql-general

From Reid Thompson
Subject Re: list of databases in C ? libpq ?
Date
Msg-id 4BEA14A8.6010901@ateb.com
Whole thread Raw
In response to Re: list of databases in C ? libpq ?  (Alex Hunsaker <badalex@gmail.com>)
List pgsql-general
On 5/7/2010 1:48 PM, Alex Hunsaker wrote:
> On Fri, May 7, 2010 at 11:18, Joao Ferreira gmail
> <joao.miguel.c.ferreira@gmail.com>  wrote:
>> Hello all,
>>
>> I need to write an application in C to read the list of databases
>> currently in the server. very much like a "psql -l"...
>
The first example in the online docs does exactly that...
http://www.postgresql.org/docs/8.1/static/libpq-example.html

$ cc -I /usr/include/postgresql-8.4/ -lpq libpq.c -o libpqex

$ ./libpqex dbname=test
datname        datdba         encoding       datcollate     datctype       datistemplate  datallowconn
datconnlimit   datlastsysoid  datfrozenxid   dattablespace  datconfig      datacl

template1      10             6              en_US.UTF-8    en_US.UTF-8    t              t              -1
           11563          648            1663                          {=c/postgres,postgres=CTc/postgres}
template0      10             6              en_US.UTF-8    en_US.UTF-8    t              f              -1
           11563          648            1663                          {=c/postgres,postgres=CTc/postgres}
postgres       10             6              en_US.UTF-8    en_US.UTF-8    f              t              -1
           11563          648            1663
test           16384          6              en_US.UTF-8    en_US.UTF-8    f              t              -1
           11563          648            1663
sigcap         16438          0              en_US.UTF-8    en_US.UTF-8    f              t              -1
           11563          648            1663


pgsql-general by date:

Previous
From: Josh Kupershmidt
Date:
Subject: Re: Pulling data from a constraint def
Next
From: Luis Guillermo Dangel
Date:
Subject: Question about Beta for Windows 64 bits