Psycopg 3.2 已发布 —— Psycopg

  • Psycopg 3.2 Released: After almost two years with 846 commits, more than 700 new tests, and over 20000 changes in 310 files, Psycopg 3.2 is out. It brings new features and hopes to have no meaningful non-backward compatible changes. The full list of changes is in the changelog.

    • Numpy Scalars Support: Numpy scalars are now supported for storage in the database automatically and the operation is efficient. A conversion between Numpy and PostgreSQL arrays is on the back burner but can be implemented if needed.
    • PostgreSQL Parameters: Psycopg uses placeholders like %s and %(name)s. It now converts to PostgreSQL's number-based placeholder format ($1, $2...). Raw query cursors can be used to execute queries in PostgreSQL format, which may be more familiar to PostgreSQL developers.
    • Scalar Row Factory: Psycopg normally returns records as Python tuples. The new scalar_row factory returns only a single value when a query returns one. It is independent of the cursor class.
    • Libpq 17 Features: In PostgreSQL 17, libpq has new features. With Psycopg using libpq 17, it can benefit from asynchronous, safe cancellation, chunked stream results, and better interaction with PgBouncer. A capabilities object helps navigate differences.
    • Easier Interaction with Notifications: Psycopg 3 introduced a notifications generator but it was difficult to stop. New timeout and stop_after parameters provide better control over notification listening tasks.
    • Less Work for Us: An internal change has reduced code writing and maintenance. All Psycopg objects have both classic blocking and asynchronous methods. An async_to_sync conversion tool generates synchronous code from asynchronous code, reducing codebase maintenance and highlighting async/sync differences.
  • We Need Your Help: Psycopg is the de-facto standard for Python and PostgreSQL communication. Maintaining it requires a lot of work. If you're a user and want to ensure the interface is well maintained, consider sponsoring the project.
阅读 20
0 条评论