diff options
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/advanced.rst | 6 | ||||
-rw-r--r-- | doc/src/connection.rst | 22 | ||||
-rw-r--r-- | doc/src/extensions.rst | 12 | ||||
-rw-r--r-- | doc/src/module.rst | 7 | ||||
-rw-r--r-- | doc/src/usage.rst | 2 |
5 files changed, 43 insertions, 6 deletions
diff --git a/doc/src/advanced.rst b/doc/src/advanced.rst index eecbcfd..82754ee 100644 --- a/doc/src/advanced.rst +++ b/doc/src/advanced.rst @@ -291,7 +291,7 @@ something to read:: else: conn.poll() while conn.notifies: - notify = conn.notifies.pop() + notify = conn.notifies.pop(0) print "Got NOTIFY:", notify.pid, notify.channel, notify.payload Running the script and executing a command such as :sql:`NOTIFY test, 'hello'` @@ -312,6 +312,10 @@ received from a previous version server will have the Added `~psycopg2.extensions.Notify` object and handling notification payload. +.. versionchanged:: 2.7 + The `~connection.notifies` attribute is writable: it is possible to + replace it with any object exposing an `!append()` method. An useful + example would be to use a `~collections.deque` object. .. index:: diff --git a/doc/src/connection.rst b/doc/src/connection.rst index 07e494a..cceef1e 100644 --- a/doc/src/connection.rst +++ b/doc/src/connection.rst @@ -419,8 +419,8 @@ The ``connection`` class By default, any query execution, including a simple :sql:`SELECT` will start a transaction: for long-running programs, if no further - action is taken, the session will remain "idle in transaction", a - condition non desiderable for several reasons (locks are held by + action is taken, the session will remain "idle in transaction", an + undesirable condition for several reasons (locks are held by the session, tables bloat...). For long lived scripts, either ensure to terminate a transaction as soon as possible or use an autocommit connection. @@ -483,13 +483,21 @@ The ``connection`` class ['NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo"\n', 'NOTICE: CREATE TABLE will create implicit sequence "foo_id_seq" for serial column "foo.id"\n'] + .. versionchanged:: 2.7 + The `!notices` attribute is writable: the user may replace it + with any Python object exposing an `!append()` method. If + appending raises an exception the notice is silently + dropped. + To avoid a leak in case excessive notices are generated, only the last - 50 messages are kept. + 50 messages are kept. This check is only in place if the `!notices` + attribute is a list: if any other object is used it will be up to the + user to guard from leakage. You can configure what messages to receive using `PostgreSQL logging configuration parameters`__ such as ``log_statement``, ``client_min_messages``, ``log_min_duration_statement`` etc. - + .. __: http://www.postgresql.org/docs/current/static/runtime-config-logging.html @@ -506,6 +514,12 @@ The ``connection`` class the payload was not accessible. To keep backward compatibility, `!Notify` objects can still be accessed as 2 items tuples. + .. versionchanged:: 2.7 + The `!notifies` attribute is writable: the user may replace it + with any Python object exposing an `!append()` method. If + appending raises an exception the notification is silently + dropped. + .. attribute:: cursor_factory diff --git a/doc/src/extensions.rst b/doc/src/extensions.rst index dea1041..84e1241 100644 --- a/doc/src/extensions.rst +++ b/doc/src/extensions.rst @@ -197,6 +197,18 @@ functionalities defined by the |DBAPI|_. .. versionadded:: 2.2.0 +.. function:: libpq_version() + + Return the version number of the ``libpq`` dynamic library loaded as an + integer, in the same format of `~connection.server_version`. + + Raise `~psycopg2.NotSupportedError` if the ``psycopg2`` module was + compiled with a ``libpq`` version lesser than 9.1 (which can be detected + by the `~psycopg2.__libpq_version__` constant). + + .. seealso:: libpq docs for `PQlibVersion()`__. + + .. __: http://www.postgresql.org/docs/current/static/libpq-misc.html#LIBPQ-PQLIBVERSION .. _sql-adaptation-objects: diff --git a/doc/src/module.rst b/doc/src/module.rst index 8de9f87..7f8a29b 100644 --- a/doc/src/module.rst +++ b/doc/src/module.rst @@ -109,6 +109,13 @@ The module interface respects the standard defined in the |DBAPI|_. by the interface. For `psycopg2` is ``pyformat``. See also :ref:`query-parameters`. +.. data:: __libpq_version__ + + Integer constant reporting the version of the ``libpq`` library this + ``psycopg2`` module was compiled with (in the same format of + `~connection.server_version`). If this value is greater or equal than + ``90100`` then you may query the version of the actually loaded library + using the `~psycopg2.extensions.libpq_version()` function. .. index:: diff --git a/doc/src/usage.rst b/doc/src/usage.rst index e83b128..9dd31df 100644 --- a/doc/src/usage.rst +++ b/doc/src/usage.rst @@ -679,7 +679,7 @@ older versions). By default even a simple :sql:`SELECT` will start a transaction: in long-running programs, if no further action is taken, the session will - remain "idle in transaction", a condition non desiderable for several + remain "idle in transaction", an undesirable condition for several reasons (locks are held by the session, tables bloat...). For long lived scripts, either make sure to terminate a transaction as soon as possible or use an autocommit connection. |