Re: [gnome-db] Postgres: listing tables in a database



On Thu, 25 Nov 2004 21:32:51 +0100, Murray Cumming <murrayc murrayc com> wrote:
> I am trying to get a list of the tables in each database on my Postgres
> server. I'm not sure how I'm meant to do this. I see two possibilities:
> 
> 1. Use gda_connection_get_schema() with GDA_CONNECTION_SCHEMA_TABLES.
> According to this page, it takes a "name" parameter:
> http://www.gnome-db.org/docs/libgda/libgda-provider-class.html
> 
> The page says that the parameter is a table name, but that makes no
> sense to me, so I hope it's actually a database name, but it seems to
> return the same list of tables regardless of the name parameter.

As far as the postgres provider is concerned, the "name" argument is a
namespace argument which corresponds to Postgres's schemas selection.
If no argument is provided, then the connection's search_path argument
is used. AFAIK under Postgres you can't easily get the list of tables
for another database than the one to which you are connected.

For MySQL, the 'name' argument is not used.

So it seems the documentation if wrong there and the argument is named
"namespace".

> 
> 2. Use gda_connection_set_database(), hoping that it changes the
> behaviour of gda_connection_get_schema() with
> GDA_CONNECTION_SCHEMA_TABLES. But that does not seem to be implemented
> for Postgres:
> 
> ** (libgdamm example:8312): CRITICAL **: file gda-server-provider.c:
> line 276 (gda_server_provider_change_database): assertion `CLASS
> (provider)->change_database != NULL' failed
> 

The change_database virtual method is not implemented by the Postgres provider.

Make sure the SEARCHPATH is correctly specified in the DSN part of the
connection description to Postgres.

Cheers,

Vivien



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]