Psycopg2: Return PQhost of a connection.

Created on 6 Jun 2018  路  6Comments  路  Source: psycopg/psycopg2

In our project, we are specifying connection string with the multiple hosts. It would be great if connection object would have a method which will return PQhost because we need to know to which host we are made a connection.

Most helpful comment

The same goes for several informative functions on the connection. We have some exposed on the connection, some not, in an inconsistent way. Maybe it would be useful to have an object similar to Error.diag exposing everything the libpq knows about the libpq connection.

I'll give it a think for 2.8

All 6 comments

The same goes for several informative functions on the connection. We have some exposed on the connection, some not, in an inconsistent way. Maybe it would be useful to have an object similar to Error.diag exposing everything the libpq knows about the libpq connection.

I'll give it a think for 2.8

Thanks. We will impatiently wait for the psycopg 2.8 ))

You may actually give a hand too either with the design or the implementation as well :P

Shall we expose an object as connection.pgconn, a class PGConnection which would have internally a pointer to the PGconn struct (likely a weakref to the psycopg connection, from which to get to the PGconn) and add an array of read-only properties and methods on it? Other ideas?

Closed via MR #787. Grazie Marco :)

Actually, reopening. Only host was implemented in #787, but I'd rather have the other informative functions implemented as well.

Merged to master. Docs available here. Feedback welcome as there is still space for changes.

Was this page helpful?
0 / 5 - 0 ratings