]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
docs: improve docs about raw query cursors, add release note 560/head
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 15 Aug 2023 15:28:01 +0000 (16:28 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 15 Aug 2023 15:29:03 +0000 (16:29 +0100)
docs/advanced/cursors.rst
docs/api/cursors.rst
docs/news.rst

index f5e369ed0964c409094b6425fc51ea8195929867..7ec2e60b134794ac3f418b6b323eff6c38ba4adc 100644 (file)
@@ -191,6 +191,7 @@ directly call the fetch methods, skipping the `~ServerCursor.execute()` call:
     for record in cur:  # or cur.fetchone(), cur.fetchmany()...
         # do something with record
 
+
 .. _raw-query-cursors:
 
 Raw Query Cursors
@@ -198,11 +199,12 @@ Raw Query Cursors
 
 .. versionadded:: 3.2
 
-Raw query cursors allow users to use PostgreSQL native placeholders ($1, $2,
-etc.) in their queries instead of the standard %s placeholder. This can be
-useful when it's desirable to pass the query unmodified to PostgreSQL and rely
-on PostgreSQL's placeholder functionality, such as when dealing with a very
-complex query containing %s inside strings, dollar-quoted strings or elsewhere.
+The `RawCursor` and `AsyncRawCursor` classes allow users to use PostgreSQL
+native placeholders (``$1``, ``$2``, etc.) in their queries instead of the
+standard ``%s`` placeholder. This can be useful when it's desirable to pass
+the query unmodified to PostgreSQL and rely on PostgreSQL's placeholder
+functionality, such as when dealing with a very complex query containing
+``%s`` inside strings, dollar-quoted strings or elsewhere.
 
 One important note is that raw query cursors only accept positional arguments
 in the form of a list or tuple. This means you cannot use named arguments
index 5d0f66a23a3fa92f6a25f62d4a3257f691496ac3..b6f51f17be31f3c7e8902e071c654f75f1c4fa5d 100644 (file)
@@ -315,6 +315,20 @@ The `!Cursor` class
           is text or binary.
 
 
+The `!RawCursor` class
+----------------------
+
+.. seealso:: See :ref:`raw-query-cursors` for details.
+
+.. autoclass:: RawCursor
+
+    This `Cursor` subclass has the same interface of the parent class but
+    supports placeholders in PostgreSQL format (``$1``, ``$2``...) rather than
+    in Python format (``%s``). Only positional parameters are supported.
+
+    .. versionadded:: 3.2
+
+
 The `!ClientCursor` class
 -------------------------
 
@@ -445,8 +459,13 @@ The `!ServerCursor` class
         .. _MOVE: https://www.postgresql.org/docs/current/sql-fetch.html
 
 
-The `!AsyncCursor` class
-------------------------
+Async cursor classes
+--------------------
+
+Every `Cursor` class has an equivalent `!Async` version exposing the same
+semantic with an `!async` interface. The main interface is described in
+`AsyncCursor`.
+
 
 .. autoclass:: AsyncCursor
 
@@ -506,21 +525,24 @@ The `!AsyncCursor` class
         to iterate on the async cursor results.
 
 
-The `!AsyncClientCursor` class
-------------------------------
+
+.. autoclass:: AsyncRawCursor
+
+    This class is the `!async` equivalent of `RawCursor`. The differences 
+    w.r.t. the sync counterpart are the same described in `AsyncCursor`.
+
+    .. versionadded:: 3.2
+
 
 .. autoclass:: AsyncClientCursor
 
-    This class is the `!async` equivalent of the `ClientCursor`. The
-    difference are the same shown in `AsyncCursor`.
+    This class is the `!async` equivalent of `ClientCursor`. The differences
+    w.r.t. the sync counterpart are the same described in `AsyncCursor`.
 
     .. versionadded:: 3.1
 
 
 
-The `!AsyncServerCursor` class
-------------------------------
-
 .. autoclass:: AsyncServerCursor
 
     This class implements a DBAPI-inspired interface as the `AsyncCursor`
index b306f6e39d6e1164aab322e6ed069e6208a02d1d..153305ef6304325024804a3d094a3bf3879fcebc 100644 (file)
@@ -15,6 +15,8 @@ Psycopg 3.2 (unreleased)
 
 - Add support for integer, floating point, boolean `NumPy scalar types`__
   (:ticket:`#332`).
+- Add :ref:`raw-query-cursors` to execute queries using placeholders in
+  PostgreSQL format (`$1`, `$2`...) (:ticket:`#560`).
 - Add support for libpq functions to close prepared statements and portals
   introduced in libpq v17 (:ticket:`#603`).
 - Disable receiving more than one result on the same cursor in pipeline mode,