>> How can I get a list of existing databases or tables ?> Check the chapter "System Catalog" in the "Developer's Guide";esp. have a look at pg_class and pg_database.
Christoph Dalitz