Skip to content

Commit

Permalink
Deploying to master from @ psycopg/psycopg-website@1d5551d 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
dvarrazzo committed Jun 23, 2024
1 parent e2a79b6 commit 7a90e1f
Show file tree
Hide file tree
Showing 14 changed files with 225 additions and 115 deletions.
104 changes: 52 additions & 52 deletions articles.xml

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions psycopg3/docs/_sources/advanced/cursors.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Class Binding Storage Placeholders See also
`ClientCursor` cient-side client-side ``%s``, ``%(name)s`` :ref:`client-side-binding-cursors`
`ServerCursor` server-side server-side ``%s``, ``%(name)s`` :ref:`server-side-cursors`
`RawCursor` server-side client-side ``$1`` :ref:`raw-query-cursors`
`RawServerCursor` server-side server-side ``$1`` :ref:`raw-query-cursors`
================= =========== =========== ==================== ==================================

If not specified by a `~Connection.cursor_factory`, `~Connection.cursor()`
Expand Down Expand Up @@ -292,6 +293,10 @@ 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
(i.e., dictionaries).

`!RawCursor` behaves like `Cursor`, in returning the complete result from the
server to the client. The `RawServerCursor` and `AsyncRawServerCursor`
implement :ref:`server-side-cursors` with raw PostgreSQL placeholders.

There are two ways to use raw query cursors:

1. Using the cursor factory:
Expand Down
62 changes: 40 additions & 22 deletions psycopg3/docs/_sources/api/cursors.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -323,20 +323,6 @@ 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
-------------------------

Expand Down Expand Up @@ -467,6 +453,30 @@ The `!ServerCursor` class
.. _MOVE: https://www.postgresql.org/docs/current/sql-fetch.html


The `!RawCursor` and `!RawServerCursor` 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


.. autoclass:: RawServerCursor

This `ServerCursor` 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



Async cursor classes
--------------------

Expand Down Expand Up @@ -534,14 +544,6 @@ semantic with an `!async` interface. The main interface is described in



.. 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 `ClientCursor`. The differences
Expand Down Expand Up @@ -582,3 +584,19 @@ semantic with an `!async` interface. The main interface is described in
...

.. automethod:: scroll


.. 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:: AsyncRawServerCursor

This class is the `!async` equivalent of `RawServerCursor`. The differences
w.r.t. the sync counterpart are the same described in `AsyncServerCursor`.

.. versionadded:: 3.2
29 changes: 28 additions & 1 deletion psycopg3/docs/_sources/api/rows.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,38 @@ the basic tuples.
Check out :ref:`row-factory-create` for information about how to use these objects.

.. autofunction:: tuple_row

Example::

>>> cur = conn.cursor(row_factory=tuple_row)
>>> cur.execute("SELECT 10 AS foo, 'hello' AS bar").fetchone()
(10, 'hello')

.. autofunction:: dict_row

Example::

>>> cur = conn.cursor(row_factory=dict_row)
>>> cur.execute("SELECT 10 AS foo, 'hello' AS bar").fetchone()
{'foo': 10, 'bar': 'hello'}

.. autofunction:: namedtuple_row

Example::

>>> cur = conn.cursor(row_factory=namedtuple_row)
>>> cur.execute("SELECT 10 AS foo, 'hello' AS bar").fetchone()
Row(foo=10, bar='hello')

.. autofunction:: scalar_row

.. versionadded:: 3.2
Example::

>>> cur = conn.cursor(row_factory=scalar_row)
>>> cur.execute("SELECT 10 AS foo, 'hello' AS bar").fetchone()
10

.. versionadded:: 3.2

.. autofunction:: class_row

Expand Down
2 changes: 1 addition & 1 deletion psycopg3/docs/_sources/news.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Psycopg 3.2 (unreleased)
(:ticket:`340`).
- Allow dumpers to return `!None`, to be converted to NULL (:ticket:`#377`).
- Add :ref:`raw-query-cursors` to execute queries using placeholders in
PostgreSQL format (`$1`, `$2`...) (:ticket:`#560`).
PostgreSQL format (`$1`, `$2`...) (:tickets:`#560, #839`).
- Add `psycopg.capabilities` object to :ref:`inspect the libpq capabilities
<capabilities>` (:ticket:`#772`).
- Add `~rows.scalar_row` to return scalar values from a query (:ticket:`#723`).
Expand Down
9 changes: 9 additions & 0 deletions psycopg3/docs/advanced/cursors.html
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@
<td><p><code class="docutils literal notranslate"><span class="pre">$1</span></code></p></td>
<td><p><a class="reference internal" href="#raw-query-cursors"><span class="std std-ref">Raw query cursors</span></a></p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="../api/cursors.html#psycopg.RawServerCursor" title="psycopg.RawServerCursor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RawServerCursor</span></code></a></p></td>
<td><p>server-side</p></td>
<td><p>server-side</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">$1</span></code></p></td>
<td><p><a class="reference internal" href="#raw-query-cursors"><span class="std std-ref">Raw query cursors</span></a></p></td>
</tr>
</tbody>
</table>
</div>
Expand Down Expand Up @@ -487,6 +493,9 @@
<p>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
(i.e., dictionaries).</p>
<p><code class="xref py py-obj docutils literal notranslate"><span class="pre">RawCursor</span></code> behaves like <a class="reference internal" href="../api/cursors.html#psycopg.Cursor" title="psycopg.Cursor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Cursor</span></code></a>, in returning the complete result from the
server to the client. The <a class="reference internal" href="../api/cursors.html#psycopg.RawServerCursor" title="psycopg.RawServerCursor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RawServerCursor</span></code></a> and <a class="reference internal" href="../api/cursors.html#psycopg.AsyncRawServerCursor" title="psycopg.AsyncRawServerCursor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">AsyncRawServerCursor</span></code></a>
implement <a class="reference internal" href="#server-side-cursors"><span class="std std-ref">Server-side cursors</span></a> with raw PostgreSQL placeholders.</p>
<p>There are two ways to use raw query cursors:</p>
<ol class="arabic simple">
<li><p>Using the cursor factory:</p></li>
Expand Down
Loading

0 comments on commit 7a90e1f

Please sign in to comment.