Adding ConnectionInfo object documentation

I'm still fought whether docs should be in the C module or in the .rst.
I'd prefer the first because DRY, but writing multiline strings in C
really sucks.
This commit is contained in:
Daniele Varrazzo 2018-10-11 23:55:36 +01:00
parent 0e2b516a3c
commit 9ddf59959f
4 changed files with 31 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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, )

View File

@ -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)