Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address reviews
  • Loading branch information
erlend-aasland committed Nov 24, 2022
commit 86a2c43ad791f0b6e8b0487b58cc5eb0e6a216f6
9 changes: 6 additions & 3 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ Connection objects

.. attribute:: row_factory

The default :attr:`~Cursor.row_factory`
The initial :attr:`~Cursor.row_factory`
for :class:`Cursor` objects created from this connection.
Assigning to this attribute does not affect the :attr:`!row_factory`
of existing cursors belonging to this connection, only new ones.
Expand Down Expand Up @@ -2364,14 +2364,14 @@ so all cursors created from the connection will use the same row factory.
:class:`!Row` provides indexed and case-insensitive named access to columns,
with minimal memory overhead and performance impact over a :class:`!tuple`.
To use :class:`!Row` as a row factory,
simply assign it to the :attr:`Connection.row_factory` attribute:
assign it to the :attr:`!row_factory` attribute:

.. doctest::

>>> con = sqlite3.connect(":memory:")
>>> con.row_factory = sqlite3.Row

Query results are now returned as :class:`!Row` instances:
Queries now return :class:`!Row` objects:

.. doctest::

Expand All @@ -2386,6 +2386,9 @@ Query results are now returned as :class:`!Row` instances:
>>> row["RADIUS"] # Column names are case-insensitive.
6378

To create and use a custom :attr:`~Cursor.row_factory`,
in this case returning a :class:`dict` mapping column names to values:

.. doctest::
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated

>>> def dict_factory(cursor, row):
Expand Down