0

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?

kzangeli
  • 403
  • 2
  • 8
  • Try this? https://stackoverflow.com/questions/11650018/libpq-code-to-create-list-and-delete-databases-c-vc-postgresql – richyen Dec 21 '20 at 08:46

1 Answers1

1

You can run a metadata query like

SELECT ... FROM pg_database;

The columns you select will depend on the information you need.
Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263