Version 0.55 of package Pg has just been released in NonGNU ELPA. You can now find it in M-x list-packages RET.
Pg describes itself as: ================================================= Socket-level interface to the PostgreSQL database ================================================= More at https://elpa.nongnu.org/nongnu/pg.html ## Summary: # pg.el -- Emacs Lisp socket-level interface to the PostgreSQL RDBMS [](https://www.gnu.org/licenses/gpl-3.0.html) [](https://github.com/emarsden/pg-el/) [](https://melpa.org/#/pg) [](https://github.com/emarsden/pg-el/actions/) [](https://github.com/emarsden/pg-el/actions/) ## Recent NEWS: # Changelog ## [0.55] - 2025-06-29 - New error class `pg-duplicate-prepared-statement`. - New function `pg-connect/direct-tls` to establish a direct TLS connection to PostgreSQL, rather than the STARTTLS-like method used in the standard wire protocol. This connection method is implemented from PostgreSQL v18 (currently in beta). It requires ALPN support in Emacs, which is not yet committed. - The `pg-sync` function tries a little harder to resynchronize the data stream with the backend, by reading and discarding additional message types that cannot lead to data loss. - Recognize the hosted PostgreSQL provider thenile.dev as variant `thenile` and implement some workarounds for its limitations. ## [0.54] - 2025-05-03 - Handle `ParameterStatus` and `NotificationResponse` messages in `pg-fetch`. - New function `pg-set-client-encoding` to set the client-side encoding for data sent to the backend. Calling this function sends an SQL request to the backend telling it of the new client encoding, and sets the per-connection client encoding (accessible via `pgcon-client-encoding`). It also checks that the requested client encoding is one supported by PostgreSQL. Note that most of the PostgreSQL variants only support UTF8 as a client-encoding. - Implement workaround for `pg-column-default` for Google Spanner and QuestDB. - Fix for parsing empty arrays. - New subclass of `pg-error` `pg-transaction-missing` triggered by an attempt to rollback with no transaction in progress. - Add preliminary support for the ReadySet PostgreSQL proxy as a PostgreSQL variant. - Add preliminary support for the YottaDB Octo database as a PostgreSQL variant. ## [0.53] - 2025-04-19 - In `pg-sync`, try to read the `ReadyForQuery` message sent by the backend. - Add test code for the PgDog and PgCat sharding connection poolers. - Implement workarounds for the RisingWave variant in `pg-table-comment` and `pg-column-comment` and their companion setf functions. - Populate our oid<->typname mappings with predefined data for variants that lack a properly populated `pg_type` table (this is the case for GreptimeDB, which contains invalud information such as `UInt8` <-> 7). Although strictly speaking there is no guarantee that this internal information will remain unchanged in future PostgreSQL releases, it is unlikely to change. ## [0.52] - 2025-04-06 - In `pg-fetch-prepared`, close the portal after fetching the tuple data. - Provide a basic stub implementation for `pg-table-owner` for CrateDB. - Add code to detect the Greenplum PostgreSQL variant. ## [0.51] - 2025-03-29 - In `pg-connect/uri`, call `url-unhex-string` on user/password only if non-nil. This restores the ability to fall back to `PGUSER` and `PGPASSWORD` environment variables. Patch from @akurth. - Fix bug in `pg-table-comment` function and in the associated setf function. - Provide an empty implementation of `pg-column-default` and `pg-table-comment` for the YDB variant. - New error types `pg-invalid-catalog` name and `pg-timeout`. ## [0.50] - 2025-03-22 - Implement new function `pg-column-comment` with a defsetf. - Improve `cl-print-object` for a connection object when the pid and database slots are unbound. - Further workarounds in `pg-table-comment` for QuestDB and Spanner variants. - Add workarounds in `pg-column-comment` for CrateDB and QuestDB. - Add workaround in `pg-function-p` for QuestDB. - Add a custom SQL query for `pg-column-autogenerated-p` to handle limitations in the CrateDB variant. - Add workaround for variant YDB in `pg-tables`. ## [0.49] - 2025-03-08 - Implement hex-decoding for the username and password in `pg-connect/uri`. - New error classes `pg-character-not-in-repertoire` and `pg-plpgsl-error`. - New error subclasses of `pg-error`: `pg-database-error`, `pg-operational-error`, `pg-programming-error`, `pg-data-error`, `pg-integrity-error`. These are superclasses of some of the leaf error subclasses: for example the errors related to integrity violations ... ...