Skip to content

Commit 056afa8

Browse files
Erlend Egeberg Aaslanderlend-aasland
Erlend Egeberg Aasland
authored andcommitted
[3.10] pythongh-95273: Normalise sqlite3 reference wording (pythonGH-95274)
Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: CAM Gerlach <[email protected]>. (cherry picked from commit 2361908) Co-authored-by: Erlend Egeberg Aasland <[email protected]>
1 parent 7e7a570 commit 056afa8

File tree

1 file changed

+43
-42
lines changed

1 file changed

+43
-42
lines changed

Doc/library/sqlite3.rst

+43-42
Original file line numberDiff line numberDiff line change
@@ -149,24 +149,25 @@ Module functions and constants
149149

150150
.. data:: version
151151

152-
The version number of this module, as a string. This is not the version of
153-
the SQLite library.
152+
Version number of this module as a :class:`string <str>`.
153+
This is not the version of the SQLite library.
154154

155155

156156
.. data:: version_info
157157

158-
The version number of this module, as a tuple of integers. This is not the
159-
version of the SQLite library.
158+
Version number of this module as a :class:`tuple` of :class:`integers <int>`.
159+
This is not the version of the SQLite library.
160160

161161

162162
.. data:: sqlite_version
163163

164-
The version number of the run-time SQLite library, as a string.
164+
Version number of the runtime SQLite library as a :class:`string <str>`.
165165

166166

167167
.. data:: sqlite_version_info
168168

169-
The version number of the run-time SQLite library, as a tuple of integers.
169+
Version number of the runtime SQLite library as a :class:`tuple` of
170+
:class:`integers <int>`.
170171

171172

172173
.. data:: threadsafety
@@ -351,6 +352,7 @@ Module functions and constants
351352

352353
.. function:: enable_callback_tracebacks(flag, /)
353354

355+
Enable or disable callback tracebacks.
354356
By default you will not get any tracebacks in user-defined functions,
355357
aggregates, converters, authorizer callbacks etc. If you want to debug them,
356358
you can call this function with *flag* set to ``True``. Afterwards, you will
@@ -392,6 +394,7 @@ Connection Objects
392394

393395
.. method:: cursor(factory=Cursor)
394396

397+
Create and return a :class:`Cursor` object.
395398
The cursor method accepts a single optional parameter *factory*. If
396399
supplied, this must be a callable returning an instance of :class:`Cursor`
397400
or its subclasses.
@@ -518,9 +521,9 @@ Connection Objects
518521

519522
.. method:: interrupt()
520523

521-
You can call this method from a different thread to abort any queries that might
522-
be executing on the connection. The query will then abort and the caller will
523-
get an exception.
524+
Call this method from a different thread to abort any queries that might
525+
be executing on the connection.
526+
Aborted queries will raise an exception.
524527

525528

526529
.. method:: set_authorizer(authorizer_callback)
@@ -620,10 +623,9 @@ Connection Objects
620623

621624
.. attribute:: row_factory
622625

623-
You can change this attribute to a callable that accepts the cursor and the
624-
original row as a tuple and will return the real result row. This way, you can
625-
implement more advanced ways of returning results, such as returning an object
626-
that can also access columns by name.
626+
A callable that accepts two arguments,
627+
a :class:`Cursor` object and the raw row results as a :class:`tuple`,
628+
and returns a custom object representing an SQLite row.
627629

628630
Example:
629631

@@ -641,31 +643,28 @@ Connection Objects
641643
642644
.. attribute:: text_factory
643645

644-
Using this attribute you can control what objects are returned for the ``TEXT``
645-
data type. By default, this attribute is set to :class:`str` and the
646-
:mod:`sqlite3` module will return :class:`str` objects for ``TEXT``.
647-
If you want to return :class:`bytes` instead, you can set it to :class:`bytes`.
646+
A callable that accepts a :class:`bytes` parameter and returns a text
647+
representation of it.
648+
The callable is invoked for SQLite values with the ``TEXT`` data type.
649+
By default, this attribute is set to :class:`str`.
650+
If you want to return ``bytes`` instead, set *text_factory* to ``bytes``.
648651

649-
You can also set it to any other callable that accepts a single bytestring
650-
parameter and returns the resulting object.
651-
652-
See the following example code for illustration:
652+
Example:
653653

654654
.. literalinclude:: ../includes/sqlite3/text_factory.py
655655

656656

657657
.. attribute:: total_changes
658658

659-
Returns the total number of database rows that have been modified, inserted, or
659+
Return the total number of database rows that have been modified, inserted, or
660660
deleted since the database connection was opened.
661661

662662

663663
.. method:: iterdump
664664

665-
Returns an iterator to dump the database in an SQL text format. Useful when
666-
saving an in-memory database for later restoration. This function provides
667-
the same capabilities as the :kbd:`.dump` command in the :program:`sqlite3`
668-
shell.
665+
Return an :term:`iterator` to dump the database as SQL source code.
666+
Useful when saving an in-memory database for later restoration.
667+
Similar to the ``.dump`` command in the :program:`sqlite3` shell.
669668

670669
Example::
671670

@@ -806,20 +805,20 @@ Cursor Objects
806805

807806
.. method:: fetchone()
808807

809-
Fetches the next row of a query result set, returning a single sequence,
810-
or :const:`None` when no more data is available.
808+
Fetch the next row of a query result set as a :class:`tuple`.
809+
Return :const:`None` if no more data is available.
811810

812811

813812
.. method:: fetchmany(size=cursor.arraysize)
814813

815-
Fetches the next set of rows of a query result, returning a list. An empty
816-
list is returned when no more rows are available.
814+
Fetch the next set of rows of a query result as a :class:`list`.
815+
Return an empty list if no more rows are available.
817816

818817
The number of rows to fetch per call is specified by the *size* parameter.
819-
If it is not given, the cursor's arraysize determines the number of rows
820-
to be fetched. The method should try to fetch as many rows as indicated by
821-
the size parameter. If this is not possible due to the specified number of
822-
rows not being available, fewer rows may be returned.
818+
If *size* is not given, :attr:`arraysize` determines the number of rows
819+
to be fetched.
820+
If fewer than *size* rows are available,
821+
as many rows as are available are returned.
823822

824823
Note there are performance considerations involved with the *size* parameter.
825824
For optimal performance, it is usually best to use the arraysize attribute.
@@ -828,9 +827,10 @@ Cursor Objects
828827

829828
.. method:: fetchall()
830829

831-
Fetches all (remaining) rows of a query result, returning a list. Note that
832-
the cursor's arraysize attribute can affect the performance of this operation.
833-
An empty list is returned when no rows are available.
830+
Fetch all (remaining) rows of a query result as a :class:`list`.
831+
Return an empty list if no rows are available.
832+
Note that the :attr:`arraysize` attribute can affect the performance of
833+
this operation.
834834

835835
.. method:: close()
836836

@@ -857,7 +857,7 @@ Cursor Objects
857857

858858
.. attribute:: lastrowid
859859

860-
This read-only attribute provides the row id of the last inserted row. It
860+
Read-only attribute that provides the row id of the last inserted row. It
861861
is only updated after successful ``INSERT`` or ``REPLACE`` statements
862862
using the :meth:`execute` method. For other statements, after
863863
:meth:`executemany` or :meth:`executescript`, or if the insertion failed,
@@ -877,16 +877,16 @@ Cursor Objects
877877

878878
.. attribute:: description
879879

880-
This read-only attribute provides the column names of the last query. To
880+
Read-only attribute that provides the column names of the last query. To
881881
remain compatible with the Python DB API, it returns a 7-tuple for each
882882
column where the last six items of each tuple are :const:`None`.
883883

884884
It is set for ``SELECT`` statements without any matching rows as well.
885885

886886
.. attribute:: connection
887887

888-
This read-only attribute provides the SQLite database :class:`Connection`
889-
used by the :class:`Cursor` object. A :class:`Cursor` object created by
888+
Read-only attribute that provides the SQLite database :class:`Connection`
889+
belonging to the cursor. A :class:`Cursor` object created by
890890
calling :meth:`con.cursor() <Connection.cursor>` will have a
891891
:attr:`connection` attribute that refers to *con*::
892892

@@ -914,7 +914,8 @@ Row Objects
914914

915915
.. method:: keys
916916

917-
This method returns a list of column names. Immediately after a query,
917+
Return a :class:`list` of column names as :class:`strings <str>`.
918+
Immediately after a query,
918919
it is the first member of each tuple in :attr:`Cursor.description`.
919920

920921
.. versionchanged:: 3.5

0 commit comments

Comments
 (0)