Psycopg 2.8 released
After about two years from the previous major release, psycopg 2.8 is finally
here!
Among the highlights, PostgreSQL errors are now mapped to Python exceptions for
a more idiomatic way to handle them. Several additions allow a better insight
of the connection status and query results.
Behind the scene, asynchronous communication and concurrency received several
improvements, and dropping support for older versions of Python gave the chance
to refactor and modernise the codebase (with the especial help from Jon
Dufresne who ruthlessly butchered our code into a streamlined pulp).
What's new in psycopg 2.7
-------------------------
New features:
- Added `~psycopg2.sql` module to generate SQL dynamically (🎫`#308`).
- Added :ref:`replication-support` (🎫`#322`). Main authors are
Oleksandr Shulgin and Craig Ringer, who deserve a huge thank you.
- Added `~psycopg2.extensions.parse_dsn()` and
`~psycopg2.extensions.make_dsn()` functions (🎟️`#321, #363`).
`~psycopg2.connect()` now can take both *dsn* and keyword arguments, merging
them together.
- Added `~psycopg2.__libpq_version__` and
`~psycopg2.extensions.libpq_version()` to inspect the version of the
``libpq`` library the module was compiled/loaded with
(🎟️`#35, #323`).
- The attributes `~connection.notices` and `~connection.notifies` can be
customized replacing them with any object exposing an `!append()` method
(🎫`#326`).
- Adapt network types to `ipaddress` objects when available. When not
enabled, convert arrays of network types to lists by default. The old `!Inet`
adapter is deprecated (🎟️`#317, #343, #387`).
- Added `~psycopg2.extensions.quote_ident()` function (🎫`#359`).
- Added `~connection.get_dsn_parameters()` connection method (🎫`#364`).
- `~cursor.callproc()` now accepts a dictionary of parameters (🎫`#381`).
- Give precedence to `!__conform__()` over superclasses to choose an object
adapter (🎫`#456`).
- Using Python C API decoding functions and codecs caching for faster
unicode encoding/decoding (🎫`#473`).
- `~cursor.executemany()` slowness addressed by
`~psycopg2.extras.execute_batch()` and `~psycopg2.extras.execute_values()`
(🎫`#491`).
- Added ``async_`` as an alias for ``async`` to support Python 3.7 where
``async`` will become a keyword (🎫`#495`).
- Unless in autocommit, do not use :sql:`default_transaction_*` settings to
control the session characteristics as it may create problems with external
connection pools such as pgbouncer; use :sql:`BEGIN` options instead
(🎫`#503`).
- `~connection.isolation_level` is now writable and entirely separated from
`~connection.autocommit`; added `~connection.readonly`,
`~connection.deferrable` writable attributes.
Bug fixes:
- Fixed error caused by missing decoding `~psycopg2.extras.LoggingConnection`
(🎫`#483`).
- Fixed integer overflow in :sql:`interval` seconds (🎫`#512`).
Other changes:
- Dropped support for Python 2.5 and 3.1.
- Dropped support for client library older than PostgreSQL 9.1 (but older
server versions are still supported).
- `~connection.isolation_level` doesn't read from the database but will return
`~psycopg2.extensions.ISOLATION_LEVEL_DEFAULT` if no value was set on the
connection.
- Empty arrays no more converted into lists if they don't have a type attached
(🎫`#506`)
What's new in psycopg 2.6.2
^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed inconsistent state in externally closed connections
(🎟️`#263, #311, #443`).
- Report the server response status on errors (such as 🎫`#281`).
- Raise `!NotSupportedError` on unhandled server response status
(🎫`#352`).
- Allow overriding string adapter encoding with no connection (🎫`#331`).
- The `~psycopg2.extras.wait_select` callback allows interrupting a
long-running query in an interactive shell using :kbd:`Ctrl-C`
(🎫`#333`).
- Fixed `!PersistentConnectionPool` on Python 3 (🎫`#348`).
- Fixed segfault on `repr()` of an unitialized connection (🎫`#361`).
- Allow adapting bytes using `~psycopg2.extensions.QuotedString` on Python 3
(🎫`#365`).
- Added support for setuptools/wheel (🎫`#370`).
- Fix build on Windows with Python 3.5, VS 2015 (🎫`#380`).
- Fixed `!errorcodes.lookup` initialization thread-safety (🎫`#382`).
- Fixed `!read()` exception propagation in copy_from (🎫`#412`).
- Fixed possible NULL TZ decref (🎫`#424`).
- `~psycopg2.errorcodes` map updated to PostgreSQL 9.5.
What's new in psycopg 2.5
-------------------------
New features:
- Added :ref:`JSON adaptation <adapt-json>`.
- Added :ref:`support for PostgreSQL 9.2 range types <adapt-range>`.
- `connection` and `cursor` objects can be used in ``with`` statements
as context managers as specified by recent |DBAPI|_ extension.
- Added `~psycopg2.extensions.Diagnostics` object to get extended info
from a database error. Many thanks to Matthew Woodcraft for the
implementation (🎫`#149`).
- Added `connection.cursor_factory` attribute to customize the default
object returned by `~connection.cursor()`.
- Added support for backward scrollable cursors. Thanks to Jon Nelson
for the initial patch (🎫`#108`).
- Added a simple way to :ref:`customize casting of composite types
<adapt-composite>` into Python objects other than namedtuples.
Many thanks to Ronan Dunklau and Tobias Oberstein for the feature
development.
- `connection.reset()` implemented using :sql:`DISCARD ALL` on server
versions supporting it.
Bug fixes:
- Properly cleanup memory of broken connections (🎫`#148`).
- Fixed bad interaction of ``setup.py`` with other dependencies in
Distribute projects on Python 3 (🎫`#153`).
Other changes:
- Added support for Python 3.3.
- Dropped support for Python 2.4. Please use Psycopg 2.4.x if you need it.
- `~psycopg2.errorcodes` map updated to PostgreSQL 9.2.
- Dropped Zope adapter from source repository. ZPsycopgDA now has its own
project at <http://github.com/psycopg/ZPsycopgDA>.
While here, let to register egg-info.
What's new in psycopg 2.4.4
---------------------------
- 'register_composite()' also works with the types implicitly defined
after a table row, not only with the ones created by 'CREATE TYPE'.
- Values for the isolation level symbolic constants restored to what
they were before release 2.4.2 to avoid breaking apps using the
values instead of the constants.
- Named DictCursor/RealDictCursor honour itersize (ticket #80).
- Fixed rollback on error on Zope (ticket #73).
- Raise 'DatabaseError' instead of 'Error' with empty libpq errors,
consistently with other disconnection-related errors: regression
introduced in release 2.4.1 (ticket #82).
What's new in psycopg 2.4.3
---------------------------
- connect() supports all the keyword arguments supported by the
database
- Added 'new_array_type()' function for easy creation of array
typecasters.
- Added support for arrays of hstores and composite types (ticket #66).
- Fixed segfault in case of transaction started with connection lost
(and possibly other events).
- Fixed adaptation of Decimal type in sub-interpreters, such as in
certain mod_wsgi configurations (ticket #52).
- Rollback connections in transaction or in error before putting them
back into a pool. Also discard broken connections (ticket #62).
- Lazy import of the slow uuid module, thanks to Marko Kreen.
- Fixed NamedTupleCursor.executemany() (ticket #65).
- Fixed --static-libpq setup option (ticket #64).
- Fixed interaction between RealDictCursor and named cursors
(ticket #67).
- Dropped limit on the columns length in COPY operations (ticket #68).
- Fixed reference leak with arguments referenced more than once
in queries (ticket #81).
- Fixed typecasting of arrays containing consecutive backslashes.
- 'errorcodes' map updated to PostgreSQL 9.1.
* New features and changes:
- Added support for Python 3.1 and 3.2. The conversion has also
brought several improvements:
- Added 'b' and 't' mode to large objects: write can deal with both
bytes strings and unicode; read can return either bytes strings
or decoded unicode.
- COPY sends Unicode data to files implementing 'io.TextIOBase'.
- Improved PostgreSQL-Python encodings mapping.
- Added a few missing encodings: EUC_CN, EUC_JIS_2004, ISO885910,
ISO885916, LATIN10, SHIFT_JIS_2004.
- Dropped repeated dictionary lookups with unicode query/parameters.
- Improvements to the named cusors:
- More efficient iteration on named cursors, fetching 'itersize'
records at time from the backend.
- The named cursors name can be an invalid identifier.
- Improvements in data handling:
- Added 'register_composite()' function to cast PostgreSQL
composite types into Python tuples/namedtuples.
- Adapt types 'bytearray' (from Python 2.6), 'memoryview' (from
Python 2.7) and other objects implementing the "Revised Buffer
Protocol" to 'bytea' data type.
- The 'hstore' adapter can work even when the data type is not
installed in the 'public' namespace.
- Raise a clean exception instead of returning bad data when
receiving bytea in 'hex' format and the client libpq can't parse
them.
- Empty lists correctly roundtrip Python -> PostgreSQL -> Python.
- Other changes:
- 'cursor.description' is provided as named tuples if available.
- The build script refuses to guess values if 'pg_config' is not
found.
- Connections and cursors are weakly referenceable.
* Bug fixes
* Fixed segfault with middleware not passing DateStyle to the client
Changes 2.3.1:
* Fixed build problem on CentOS 5.5 x86_64
Changes 2.3.0:
psycopg 2.3 aims to expose some new features introduced in PostgreSQL 9.0.
* Main new features:
- `dict` to `hstore` adapter and `hstore` to `dict` typecaster, using both
9.0 and pre-9.0 syntax.
- Two-phase commit protocol support as per DBAPI specification.
- Support for payload in notifications received from the backed.
- `namedtuple`-returning cursor.
- Query execution cancel.
This is version 2, a complete rewrite of the original code to provide
new-style classes for connection and cursor objects and other
sweet candies. Like the original, psycopg 2 was written with the aim of
being very small and fast, and stable as a rock.