.. currentmodule:: psycopg
.. index:: single: Release notes single: News
- Release binary packages including PostgreSQL 17 libpq (🎫`#852`).
- Drop !TypeDef specifications as string from public modules, as they cannot be composed by users as !typing objects previously could (🎫`#860`).
- Release Python 3.13 binary packages.
- Fix packaging metadata breaking
[c]
,[binary]
dependencies (🎫`#853`).
New top-level features
- Add support for integer, floating point, boolean NumPy scalar types (🎫`#332`).
- Add !timeout and !stop_after parameters to Connection.notifies() (🎫`340`).
- Allow dumpers to return !None, to be converted to NULL (🎫`#377`).
- Add :ref:`raw-query-cursors` to execute queries using placeholders in PostgreSQL format ($1, $2...) (🎟️`#560, #839`).
- Add capabilities object to :ref:`inspect the libpq capabilities <capabilities>` (🎫`#772`).
- Add ~rows.scalar_row to return scalar values from a query (🎫`#723`).
- Add ~Connection.cancel_safe() for encrypted and non-blocking cancellation when using libpq v17. Use such method internally to implement !KeyboardInterrupt and ~cursor.copy termination (🎫`#754`).
- The !context parameter of sql objects ~sql.Composable.as_string() and ~sql.Composable.as_bytes() methods is now optional (🎫`#716`).
- Add ~Connection.set_autocommit() on sync connections, and similar transaction control methods available on the async connections.
- Add a size parameter to ~Cursor.stream() to enable results retrieval in chunks instead of row-by-row (🎫`#794`).
New libpq wrapper features
- Add support for libpq functions to close prepared statements and portals introduced in libpq v17 (🎫`#603`).
- Add support for libpq encrypted and non-blocking query cancellation functions introduced in libpq v17 (🎫`#754`).
- Add support for libpq function to retrieve results in chunks introduced in libpq v17 (🎫`#793`).
- Add support for libpq function to change role passwords introduced in libpq v17 (🎫`#818`).
Other changes
- Drop support for Python 3.7.
- Prepared statements are now :ref:`compatible with PgBouncer <pgbouncer>`. (🎫`#589`).
- Disable receiving more than one result on the same cursor in pipeline mode, to iterate through ~Cursor.nextset(). The behaviour was different than in non-pipeline mode and not totally reliable (🎫`#604`). The Cursor now only preserves the results set of the last ~Cursor.execute(), consistently with non-pipeline mode.
- Use the simple query protocol to execute COMMIT/ROLLBACK when possible. This should make querying the PgBouncer admin database easier (🎫`#820`).
- Avoid unneeded escaping checks and memory over-allocation in text copy (🎫`#829`).
- Bundle binary package with OpenSSL 3.3.x (🎫`#847`).
- Drop macOS ARM64 binary packages for macOS versions before 14.0 and Python before 3.10 (not for our choice but for the lack of available CI runners; 🎫`#858`)
- Fix unaligned access undefined behaviour in C extension (🎫`#734`).
- Fix excessive stripping of error message prefixes (🎫`#752`).
- Allow to specify the
connect_timeout
connection parameter as float (🎫`#796`). - Improve COPY performance on macOS (🎫`#745`).
- Fix possible deadlock on pipeline exit (🎫`#685`).
- Fix overflow loading large intervals in C module (🎫`#719`).
- Fix compatibility with musl libc distributions affected by CPython issue #65821 (🎫`#725`).
- Fix multiple connection attempts when a host name resolve to multiple IP addresses (🎫`#699`).
- Use typing.Self as a more correct return value annotation of context managers and other self-returning methods (see 🎫`#708`).
- Fix empty ports handling in async multiple connection attempts (🎫`#703`).
- Fix use of
service
in connection string (regression in 3.1.13, 🎫`#694`). - Fix async connection to hosts resolving to multiple IP addresses (regression in 3.1.13, 🎫`#695`).
- Respect the :envvar:`PGCONNECT_TIMEOUT` environment variable to determine the connection timeout.
- Fix :ref:`interaction with gevent <gevent>` (🎫`#527`).
- Add support for PyPy (🎫`#686`).
- Raise DataError instead of whatever internal failure trying to dump a ~datetime.time object with with a !tzinfo specified as ~zoneinfo.ZoneInfo (ambiguous offset, see 🎫`#652`).
- Handle gracefully EINTR on signals instead of raising InterruptedError, consistently with PEP 475 guideline (🎫`#667`).
- Fix support for connection strings with multiple hosts/ports and for the
load_balance_hosts
connection parameter (🎫`#674`). - Fix memory leak receiving notifications in Python implementation (🎫`#679`).
- Fix possible hanging if a connection is closed while querying (🎫`#608`).
- Fix memory leak when ~register_*() functions are called repeatedly (🎫`#647`).
- Release Python 3.12 binary packages.
- Avoid caching the parsing results of large queries to avoid excessive memory usage (🎫`#628`).
- Fix integer overflow in C/binary extension with OID > 2^31 (🎫`#630`).
- Fix loading of intervals with days and months or years (🎫`#643`).
- Work around excessive CPU usage on Windows (reported in 🎫`#645`).
- Fix building on Solaris and derivatives (🎫`#632`).
- Fix possible lack of critical section guard in async ~AsyncCursor.executemany().
- Fix missing pipeline fetch in async ~AsyncCursor.scroll().
- Build binary packages with libpq 15.4, which allows group-readable permissions on the SSL certificate on the client (🎫`#528`).
- Allow JSON dumpers to dump bytes directly instead of str, for better compatibility with libraries like orjson and msgspec (🎫`#569`)
- Fix prepared statement cache validation when exiting pipeline mode (or ~Cursor.executemany()) in case an error occurred within the pipeline (🎫`#585`).
- Fix connect() to avoid "leaking" an open ~pq.PGconn attached to the OperationalError in case of connection failure. Error.pgconn is now a shallow copy of the real libpq connection, and the latter is closed before the exception propagates (🎫`#565`).
- Fix possible (ignored) exception on objects deletion (🎫`#591`).
- Don't clobber a Python exception raised during COPY FROM with the resulting !QueryCanceled raised as a consequence (🎫`#593`).
- Fix resetting Connection.read_only and ~Connection.deferrable to their default value using !None (🎫`#612`).
- Add support for Python 3.12.
- Fix TypeInfo.fetch() using a connection in !sql_ascii encoding (🎫`#503`).
- Fix "filedescriptor out of range" using a large number of files open in Python implementation (🎫`#532`).
- Allow JSON dumpers to be registered on !dict or any other object, as was possible in psycopg2 (🎫`#541`).
- Fix canceling running queries on process interruption in async connections (🎫`#543`).
- Fix loading ROW values with different types in the same query using the binary protocol (🎫`#545`).
- Fix dumping recursive composite types (🎫`#547`).
- Don't pollute server logs when types looked for by TypeInfo.fetch() are not found (🎫`#473`).
- Set Cursor.rowcount to the number of rows of each result set from ~Cursor.executemany() when called with !returning=True (🎫`#479`).
- Fix TypeInfo.fetch() when used with ClientCursor (🎫`#484`).
- Fix server-side cursors using row factories (🎫`#464`).
- Fix cursor.copy() with cursors using row factories (🎫`#460`).
- Fix array loading slowness compared to psycopg2 (🎫`#359`).
- Improve performance around network communication (🎫`#414`).
- Return !bytes instead of !memoryview from pq.Encoding methods (🎫`#422`).
- Fix Cursor.rownumber to return !None when the result has no row to fetch (🎫`#437`).
- Avoid error in Pyright caused by aliasing !TypeAlias (🎫`#439`).
- Fix Copy.set_types() used with varchar and name types (🎫`#452`).
- Improve performance using :ref:`row-factories` (🎫`#457`).
- Include :ref:`error classes <sqlstate-exceptions>` defined in PostgreSQL 15.
- Add support for Python 3.11 (🎫`#305`).
- Build binary packages with libpq from PostgreSQL 15.0.
- Restore the state of the connection if Cursor.stream() is terminated prematurely (🎫`#382`).
- Fix regression introduced in 3.1 with different named tuples mangling rules for non-ascii attribute names (🎫`#386`).
- Fix handling of queries with escaped percent signs (
%%
) in ClientCursor (🎫`#399`). - Fix possible duplicated BEGIN statements emitted in pipeline mode (🎫`#401`).
- Fix handling of certain invalid time zones causing problems on Windows (🎫`#371`).
- Fix segfault occurring when a loader fails initialization (🎫`#372`).
- Fix invalid SAVEPOINT issued when entering Connection.transaction() within a pipeline using an implicit transaction (🎫`#374`).
- Fix queries with repeated named parameters in ClientCursor (🎫`#378`).
- Distribute macOS arm64 (Apple M1) binary packages (🎫`#344`).
- Work around broken Homebrew installation of the libpq in a non-standard path (🎫`#364`)
- Fix possible "unrecognized service" error in async connection when no port is specified (🎫`#366`).
- Add :ref:`Pipeline mode <pipeline-mode>` (🎫`#74`).
- Add :ref:`client-side-binding-cursors` (🎫`#101`).
- Add CockroachDB support in psycopg.crdb (🎫`#313`).
- Add :ref:`Two-Phase Commit <two-phase-commit>` support (🎫`#72`).
- Add :ref:`adapt-enum` (🎫`#274`).
- Add
returning
parameter to ~Cursor.executemany() to retrieve query results (🎫`#164`). - ~Cursor.executemany() performance improved by using batch mode internally (🎫`#145`).
- Add parameters to ~Cursor.copy().
- Add :ref:`COPY Writer objects <copy-writers>`.
- Resolve domain names asynchronously in AsyncConnection.connect() (🎫`#259`).
- Add pq.PGconn.trace() and related trace functions (🎫`#167`).
- Add
prepare_threshold
parameter to Connection init (🎫`#200`). - Add
cursor_factory
parameter to Connection init. - Add Error.pgconn and Error.pgresult attributes (🎫`#242`).
- Restrict queries to be ~typing.LiteralString as per PEP 675 (🎫`#323`).
- Add explicit type cast to values converted by sql.Literal (🎫`#205`).
- Drop support for Python 3.6.
- Fix segfaults on fork on some Linux systems using ctypes implementation (🎫`#300`).
- Load bytea as bytes, not memoryview, using ctypes implementation.
- Fix missing ~Cursor.rowcount after SHOW (🎫`#343`).
- Add scripts to build macOS arm64 packages (🎫`#162`).
- Fix wrong escaping of unprintable chars in COPY (nonetheless correctly interpreted by PostgreSQL).
- Restore the connection to usable state after an error in ~Cursor.stream().
- Raise DataError instead of OverflowError loading binary intervals out-of-range.
- Distribute
manylinux2014
wheel packages (🎫`#124`).
- Raise DataError dumping arrays of mixed types (🎫`#301`).
- Fix handling of incorrect server results, with blank sqlstate (🎫`#303`).
- Fix bad Float4 conversion on ppc64le/musllinux (🎫`#304`).
- Fix Cursor.stream() slowness (🎫`#286`).
- Fix oid for lists of integers, which might cause the server choosing bad plans (🎫`#293`).
- Make Connection.cancel() on a closed connection a no-op instead of an error.
- Allow bytearray/memoryview data too as Copy.write() input (🎫`#254`).
- Fix dumping ~enum.IntEnum in text mode, Python implementation.
- Fix DataError loading arrays with dimensions information (🎫`#253`).
- Fix hanging during COPY in case of memory error (🎫`#255`).
- Fix error propagation from COPY worker thread (mentioned in 🎫`#255`).
- Leave the connection in working state after interrupting a query with Ctrl-C (🎫`#231`).
- Fix Cursor.description after a COPY ... TO STDOUT operation (🎫`#235`).
- Fix building on FreeBSD and likely other BSD flavours (🎫`#241`).
- Set Error.sqlstate when an unknown code is received (🎫`#225`).
- Add the !tzdata package as a dependency on Windows in order to handle time zones (🎫`#223`).
- Decode connection errors in the
client_encoding
specified in the connection string, if available (🎫`#194`). - Fix possible warnings in objects deletion on interpreter shutdown (🎫`#198`).
- Don't leave connections in ACTIVE state in case of error during COPY ... TO STDOUT (🎫`#203`).
- Fix crash in ~Cursor.executemany() with no input sequence (🎫`#179`).
- Fix wrong ~Cursor.rowcount after an ~Cursor.executemany() returning no rows (🎫`#178`).
- Allow to use Cursor.description if the connection is closed (🎫`#172`).
- Don't raise exceptions on ServerCursor.close() if the connection is closed (🎫`#173`).
- Fail on Connection.cursor() if the connection is closed (🎫`#174`).
- Raise ProgrammingError if out-of-order exit from transaction contexts is detected (🎟️`#176, #177`).
- Add !CHECK_STANDBY value to ~pq.ConnStatus enum.
- Fix possible "Too many open files" OS error, reported on macOS but possible on other platforms too (🎫`#158`).
- Don't clobber exceptions if a transaction block exit with error and rollback fails (🎫`#165`).
- Allow to use the module with strict strings comparison (🎫`#147`).
- Fix segfault on Python 3.6 running in
-W error
mode, related to !backport.zoneinfo (🎫`#109`). <pganssle/zoneinfo#109>`__. - Build binary package with libpq versions not affected by CVE-2021-23222 (🎫`#149`).
- Release musllinux binary packages, compatible with Alpine Linux (🎫`#141`).
- Reduce size of binary package by stripping debug symbols (🎫`#142`).
- Include typing information in the !psycopg_binary package.
- Fix type hint for sql.SQL.join() (🎫`#127`).
- Fix type hint for Connection.notifies() (🎫`#128`).
- Fix call to MultiRange.__setitem__() with a non-iterable value and a slice, now raising a TypeError (🎫`#129`).
- Fix disable cursors methods after close() (🎫`#125`).
- Fix use of the wrong dumper reusing cursors with the same query but different parameter types (🎫`#112`).
First stable release. Changed from 3.0b1:
- Add :ref:`adapt-shapely` (🎫`#80`).
- Add :ref:`adapt-multirange` (🎫`#75`).
- Add pq.__build_version__ constant.
- Don't use the extended protocol with COPY, (🎟️`#78, #82`).
- Add
context
parameter to ~Connection.connect() (🎫`#83`). - Fix selection of dumper by oid after ~Copy.set_types().
- Drop !Connection.client_encoding. Use ConnectionInfo.encoding to read it, and a :sql:`SET` statement to change it.
- Add binary packages for Python 3.10 (🎫`#103`).
- First public release on PyPI.