Skip to content

Commit e14c4d5

Browse files
miss-islingtonErlend Egeberg Aasland
and
Erlend Egeberg Aasland
authored
gh-95273: Normalise sqlite3 reference wording (GH-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 f281182 commit e14c4d5

File tree

1 file changed

+48
-45
lines changed

1 file changed

+48
-45
lines changed

Doc/library/sqlite3.rst

Lines changed: 48 additions & 45 deletions
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
@@ -369,6 +370,7 @@ Module functions and constants
369370

370371
.. function:: enable_callback_tracebacks(flag, /)
371372

373+
Enable or disable callback tracebacks.
372374
By default you will not get any tracebacks in user-defined functions,
373375
aggregates, converters, authorizer callbacks etc. If you want to debug them,
374376
you can call this function with *flag* set to :const:`True`. Afterwards, you
@@ -428,6 +430,7 @@ Connection Objects
428430

429431
.. method:: cursor(factory=Cursor)
430432

433+
Create and return a :class:`Cursor` object.
431434
The cursor method accepts a single optional parameter *factory*. If
432435
supplied, this must be a callable returning an instance of :class:`Cursor`
433436
or its subclasses.
@@ -638,9 +641,9 @@ Connection Objects
638641

639642
.. method:: interrupt()
640643

641-
You can call this method from a different thread to abort any queries that might
642-
be executing on the connection. The query will then abort and the caller will
643-
get an exception.
644+
Call this method from a different thread to abort any queries that might
645+
be executing on the connection.
646+
Aborted queries will raise an exception.
644647

645648

646649
.. method:: set_authorizer(authorizer_callback)
@@ -745,10 +748,9 @@ Connection Objects
745748

746749
.. attribute:: row_factory
747750

748-
You can change this attribute to a callable that accepts the cursor and the
749-
original row as a tuple and will return the real result row. This way, you can
750-
implement more advanced ways of returning results, such as returning an object
751-
that can also access columns by name.
751+
A callable that accepts two arguments,
752+
a :class:`Cursor` object and the raw row results as a :class:`tuple`,
753+
and returns a custom object representing an SQLite row.
752754

753755
Example:
754756

@@ -766,31 +768,28 @@ Connection Objects
766768
767769
.. attribute:: text_factory
768770

769-
Using this attribute you can control what objects are returned for the ``TEXT``
770-
data type. By default, this attribute is set to :class:`str` and the
771-
:mod:`sqlite3` module will return :class:`str` objects for ``TEXT``.
772-
If you want to return :class:`bytes` instead, you can set it to :class:`bytes`.
771+
A callable that accepts a :class:`bytes` parameter and returns a text
772+
representation of it.
773+
The callable is invoked for SQLite values with the ``TEXT`` data type.
774+
By default, this attribute is set to :class:`str`.
775+
If you want to return ``bytes`` instead, set *text_factory* to ``bytes``.
773776

774-
You can also set it to any other callable that accepts a single bytestring
775-
parameter and returns the resulting object.
776-
777-
See the following example code for illustration:
777+
Example:
778778

779779
.. literalinclude:: ../includes/sqlite3/text_factory.py
780780

781781

782782
.. attribute:: total_changes
783783

784-
Returns the total number of database rows that have been modified, inserted, or
784+
Return the total number of database rows that have been modified, inserted, or
785785
deleted since the database connection was opened.
786786

787787

788788
.. method:: iterdump
789789

790-
Returns an iterator to dump the database in an SQL text format. Useful when
791-
saving an in-memory database for later restoration. This function provides
792-
the same capabilities as the :kbd:`.dump` command in the :program:`sqlite3`
793-
shell.
790+
Return an :term:`iterator` to dump the database as SQL source code.
791+
Useful when saving an in-memory database for later restoration.
792+
Similar to the ``.dump`` command in the :program:`sqlite3` shell.
794793

795794
Example::
796795

@@ -871,7 +870,7 @@ Connection Objects
871870

872871
.. method:: getlimit(category, /)
873872

874-
Get a connection run-time limit. *category* is the limit category to be
873+
Get a connection runtime limit. *category* is the limit category to be
875874
queried.
876875

877876
Example, query the maximum length of an SQL statement::
@@ -886,7 +885,7 @@ Connection Objects
886885

887886
.. method:: setlimit(category, limit, /)
888887

889-
Set a connection run-time limit. *category* is the limit category to be
888+
Set a connection runtime limit. *category* is the limit category to be
890889
set. *limit* is the new limit. If the new limit is a negative number, the
891890
limit is unchanged.
892891

@@ -905,7 +904,7 @@ Connection Objects
905904

906905
.. method:: serialize(*, name="main")
907906

908-
This method serializes a database into a :class:`bytes` object. For an
907+
Serialize a database into a :class:`bytes` object. For an
909908
ordinary on-disk database file, the serialization is just a copy of the
910909
disk file. For an in-memory database or a "temp" database, the
911910
serialization is the same sequence of bytes which would be written to
@@ -924,6 +923,8 @@ Connection Objects
924923

925924
.. method:: deserialize(data, /, *, name="main")
926925

926+
Deserialize a :meth:`serialized <serialize>` database into a
927+
:class:`Connection`.
927928
This method causes the database connection to disconnect from database
928929
*name*, and reopen *name* as an in-memory database based on the
929930
serialization contained in *data*. Deserialization will raise
@@ -1003,20 +1004,20 @@ Cursor Objects
10031004

10041005
.. method:: fetchone()
10051006

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

10091010

10101011
.. method:: fetchmany(size=cursor.arraysize)
10111012

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

10151016
The number of rows to fetch per call is specified by the *size* parameter.
1016-
If it is not given, the cursor's arraysize determines the number of rows
1017-
to be fetched. The method should try to fetch as many rows as indicated by
1018-
the size parameter. If this is not possible due to the specified number of
1019-
rows not being available, fewer rows may be returned.
1017+
If *size* is not given, :attr:`arraysize` determines the number of rows
1018+
to be fetched.
1019+
If fewer than *size* rows are available,
1020+
as many rows as are available are returned.
10201021

10211022
Note there are performance considerations involved with the *size* parameter.
10221023
For optimal performance, it is usually best to use the arraysize attribute.
@@ -1025,9 +1026,10 @@ Cursor Objects
10251026

10261027
.. method:: fetchall()
10271028

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

10321034
.. method:: close()
10331035

@@ -1054,7 +1056,7 @@ Cursor Objects
10541056

10551057
.. attribute:: lastrowid
10561058

1057-
This read-only attribute provides the row id of the last inserted row. It
1059+
Read-only attribute that provides the row id of the last inserted row. It
10581060
is only updated after successful ``INSERT`` or ``REPLACE`` statements
10591061
using the :meth:`execute` method. For other statements, after
10601062
:meth:`executemany` or :meth:`executescript`, or if the insertion failed,
@@ -1074,16 +1076,16 @@ Cursor Objects
10741076

10751077
.. attribute:: description
10761078

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

10811083
It is set for ``SELECT`` statements without any matching rows as well.
10821084

10831085
.. attribute:: connection
10841086

1085-
This read-only attribute provides the SQLite database :class:`Connection`
1086-
used by the :class:`Cursor` object. A :class:`Cursor` object created by
1087+
Read-only attribute that provides the SQLite database :class:`Connection`
1088+
belonging to the cursor. A :class:`Cursor` object created by
10871089
calling :meth:`con.cursor() <Connection.cursor>` will have a
10881090
:attr:`connection` attribute that refers to *con*::
10891091

@@ -1111,7 +1113,8 @@ Row Objects
11111113

11121114
.. method:: keys
11131115

1114-
This method returns a list of column names. Immediately after a query,
1116+
Return a :class:`list` of column names as :class:`strings <str>`.
1117+
Immediately after a query,
11151118
it is the first member of each tuple in :attr:`Cursor.description`.
11161119

11171120
.. versionchanged:: 3.5

0 commit comments

Comments
 (0)