diff --git a/doc/src/connection.rst b/doc/src/connection.rst index bd192d6c..59c88bb3 100644 --- a/doc/src/connection.rst +++ b/doc/src/connection.rst @@ -600,19 +600,12 @@ The ``connection`` class .. index:: - pair: Backend; Host + pair: Connection; Info - .. attribute:: host + .. attribute:: info - The server host name of the active connection. - - This can be a host name, an IP address, or a directory path if the - connection is via Unix socket. (The path case can be distinguished - because it will always be an absolute path, beginning with ``/``.) - - .. seealso:: libpq docs for `PQhost()`__ for details. - - .. __: https://www.postgresql.org/docs/current/static/libpq-status.html#LIBPQ-PQHOST + A `~psycopg2.extensions.ConnectionInfo` object exposing information + about the native libpq connection. .. versionadded:: 2.8.0 diff --git a/doc/src/extensions.rst b/doc/src/extensions.rst index 159774b8..520858c5 100644 --- a/doc/src/extensions.rst +++ b/doc/src/extensions.rst @@ -154,6 +154,15 @@ introspection etc. Close the object and remove it from the database. + +.. autoclass:: ConnectionInfo + + .. versionadded:: 2.8 + + .. autoattribute:: host + + + .. class:: Column Description of one result column, exposed as items of the diff --git a/lib/extensions.py b/lib/extensions.py index 3111d415..3e23906e 100644 --- a/lib/extensions.py +++ b/lib/extensions.py @@ -61,7 +61,7 @@ from psycopg2._psycopg import ( # noqa adapt, adapters, encodings, connection, cursor, lobject, Xid, libpq_version, parse_dsn, quote_ident, string_types, binary_types, new_type, new_array_type, register_type, - ISQLQuote, Notify, Diagnostics, Column, + ISQLQuote, Notify, Diagnostics, Column, ConnectionInfo, QueryCanceledError, TransactionRollbackError, set_wait_callback, get_wait_callback, encrypt_password, ) diff --git a/psycopg/conninfo_type.c b/psycopg/conninfo_type.c index b0258eeb..b10a7f9c 100644 --- a/psycopg/conninfo_type.c +++ b/psycopg/conninfo_type.c @@ -30,7 +30,15 @@ static const char host_doc[] = - "The server host name of the active connection."; +"The server host name of the connection.\n" +"\n" +"This can be a host name, an IP address, or a directory path if the\n" +"connection is via Unix socket. (The path case can be distinguished\n" +"because it will always be an absolute path, beginning with ``/``.)\n" +"\n" +".. seealso:: libpq docs for `PQhost()`__ for details.\n" +".. __: https://www.postgresql.org/docs/current/static/libpq-status.html" + "#LIBPQ-PQHOST"; static PyObject * host_get(connInfoObject *self) @@ -88,7 +96,14 @@ conninfo_dealloc(connInfoObject* self) /* object type */ static const char connInfoType_doc[] = - "Details of a database connection."; +"Details about the native PostgreSQL database connection.\n" +"\n" +"This class exposes several `informative functions`__ about the status\n" +"of the libpq connection.\n" +"\n" +"Objects of this class are exposed as the `connection.info` attribute.\n" +"\n" +".. __: https://www.postgresql.org/docs/current/static/libpq-status.html"; PyTypeObject connInfoType = { PyVarObject_HEAD_INIT(NULL, 0)