.. currentmodule:: psycopg
.. index::
single: Release notes
single: News
- Fix possible spurious connection timeout in systems with very long uptimes in C extension (🎫`#1280`).
- Fix client-side adaptation of enums whose name require quotes (🎫`#1298`).
- Consistently populate ~Cursor.statusmessage after ~Cursor.executemany() (🎫`#1302`).
- Retain Error.pgconn when raising a single exception for multiple connection attempt errors (🎫`#1246`).
- Return a proper error when server sends
ErrorResponsefor aSyncafter aParse(🎫`#1260`).
Fix race condition in adapters at startup (🎫`#1230`).
Fix iteration on server-side cursors (🎫`#1226`).
New top-level features
- Add :ref:`template strings queries <template-strings>` (🎫`#1054`).
- More flexible :ref:`composite adaptation<adapt-composite>`: it is now possible to adapt Python objects to PostgreSQL composites and back even if they are not sequences or if they take keyword arguments (🎫`#932`, 🎫`#1202`).
- Cursors are now iterators, not just iterables. This means you can call
next
(cur)or anext(cur), which is useful as a :ref:`type-safe expression <typing-fetchone>` (🎫`#1064`). - Add Cursor.set_result() and Cursor.results() to move across the result sets of queries executed though ~Cursor.executemany() or ~Cursor.execute() with multiple statements (🎟️`#1080, #1170`).
- Add :ref:`transaction-status` to report the status during and after a ~Connection.transaction() block (🎫`#969`).
- Allow to change loaders using ~adapt.AdaptersMap.register_loader() on Cursor.adapters after a query result has been already returned (🎫`#884`).
New libpq wrapper features
- Add pq.PGconn.used_gssapi attribute and Capabilities.has_used_gssapi() function (🎫`#1138`).
- Add ConnectionInfo.full_protocol_version attribute, Capabilities.has_full_protocol_version() function (🎫`#1079`).
Other changes
Disable default GSSAPI preferential connection in the binary package (🎫`#1136`).
Warning
Please explicitly set the gssencmode connection parameter or the :envvar:`PGGSSENCMODE` environment variable to interact reliably with the GSSAPI.
- Show the host name in the error message in case of name resolution error (🎫`#1205`).
- Fix Cursor.copy() and AsyncCursor.copy() to hold the connection lock for the entire operation, preventing concurrent access issues (🎫`#1210`).
- Fix GSSAPI check with C extension built with libpq < v16 (🎫`#1216`).
- Allow copy to pass different types per column, as long as the database can convert them. Regression introduced in 3.2.11 (🎫`#1192`).
- Fix spurious readiness flags in some of the wait functions (🎫`#1141`).
- Fix high CPU usage using the
wait_cfunction on Windows (🎫`#645`). - Fix bad data on error in binary copy (🎫`#1147`).
- Respect Copy.set_types() in TEXT copy in C version, consistently with the Python version (🎫`#1153`).
- Don't raise warning, and don't leak resources, if a builtin function is used as JSON dumper/loader function (🎫`#1165`).
- Improve performance of Python conversion on results loading (🎫`#1155`).
Fix !TypeError shadowing ~asyncio.CancelledError upon task cancellation during pipeline execution (🎫`#1005`).
Fix memory leak when lambda/local functions are used as argument for ~.psycopg.types.json.set_json_dumps(), ~.psycopg.types.json.set_json_loads() (🎫`#1108`).
Fix coordination of ~Cursor.executemany() with other concurrent operations on other cursors (🎫`#1130`).
Fix leak receiving notifications if the ~Connection.notifies() generator is not called (🎫`#1091`).
Warning
This bugfix required the introduction of a change in :ref:`notifies reception <async-notify>` behaviour.
If a notification is received when a handler is registered via ~Connection.add_notify_handler() and the ~Connection.notifies() generator is not running the notification will not be yielded by the generator. This is a behaviour similar to before Psycopg 3.2.4, but notifications are not lost if no handler is registered.
Using both the generator and handlers to receive notifications on the same connection is therefore deprecated and will now generate a runtime warning.
Add support for Python 3.14 (🎫`#1053`).
Fix psycopg_binary.__version__.
Raise a warning if a GSSAPI connection is obtained using the
gssencmode=preferlibpq default (see 🎫`#1136`).Warning
In a future Psycopg version the default in the binary package will be changed to
disable. If you need to interact with the GSSAPI reliably you should explicitly set the gssencmode parameter in the connection string or the :envvar:`PGGSSENCMODE` environment variable topreferorrequire.
- Revert the libpq included in the binary packages from conda forge to vcpkg because GSS connection crashes (🎫`#1088`).
- Fix DateFromTicks and TimeFromTicks return values to return a date and a time referred to the UTC timezone rather than to the local timezone. For consistency, TimestampFromTicks to return a datetime in UTC rather than in the local timezone (🎫`#1058`).
- Fix ~Cursor.rownumber after using ~AsyncServerCursor.scroll() on AsyncServerCursor (🎫`#1066`).
- Fix interval parsing with days or other parts and negative time in C module (🎫`#1071`).
- Don't process further connection attempts after Ctrl-C (🎫`#1077`).
- Fix cursors to correctly iterate over rows even if their row factory returns None (🎫`#1073`).
- Fix ConnectionInfo.port when the port is specified as an empty string (🎫`#1078`).
- Report all the attempts error messages in the exception raised for a connection failure (🎫`#1069`).
- Improve logging on connection (🎫`#1085`).
- Add support for PostgreSQL 18 libpq (🎫`#1082`).
- Fix connection semantic when using
target_session_attrs=prefer-standby(🎫`#1021`).
- 3x faster UUID loading thanks to C implementation (🎟️`#447, #998`).
Don't lose notifies received whilst the ~Connection.notifies() iterator is not running (🎫`#962`).
Warning
If you were using notifications to bridge the time between issuing a LISTEN on a channel and starting the iterator you might receive duplicate notifications.
Make sure that the notifies callback is called during the use of the ~Connection.notifies() generator (🎫`#972`).
Raise the correct error returned by the database (such as !AdminShutdown or !IdleInTransactionSessionTimeout) instead of a generic OperationalError when a server error causes a client disconnection (🎫`#988`).
Build macOS dependencies from sources instead using the Homebrew versions in order to avoid problems with
MACOSX_DEPLOYMENT_TARGET(🎫`#858`).Bump libpq to 17.2 in Linux and macOS binary packages.
Bump libpq to 16.4 in Windows binary packages, using the vcpkg library (🎫`#966`).
- 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_timeoutconnection 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
servicein 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_hostsconnection 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
returningparameter 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_thresholdparameter to Connection init (🎫`#200`). - Add
cursor_factoryparameter 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
manylinux2014wheel 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_encodingspecified 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 errormode, 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
contextparameter 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.