kzangeli
kzangeli

Reputation: 448

Retrieve a list of the databases from postgres server via libpq

I've tried to find a way to ask the postgres server for the current list of databases (and later list and describe the tables) from a C program using the libpq library. Currently I'm doing a (simplified) popen("psql --command '\\l'") but this is not really how I would like to solve the problem ... Is there any way of asking the postgres server for the information I need via a libpq function?

Upvotes: 0

Views: 217

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246403

You can run a metadata query like

SELECT ... FROM pg_database;

The columns you select will depend on the information you need.

Upvotes: 1

Related Questions