Skip to content

Commit 4130c33

Browse files
pythongh-95273: Normalise sqlite3 reference wording
1 parent a5dde0f commit 4130c33

File tree

1 file changed

+45
-43
lines changed

1 file changed

+45
-43
lines changed

Doc/library/sqlite3.rst

+45-43
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ Module functions and constants
139139

140140
.. data:: version
141141

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

145145
.. deprecated-removed:: 3.12 3.14
146146
This constant used to reflect the version number of the ``pysqlite``
@@ -150,8 +150,8 @@ Module functions and constants
150150

151151
.. data:: version_info
152152

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

156156
.. deprecated-removed:: 3.12 3.14
157157
This constant used to reflect the version number of the ``pysqlite``
@@ -161,12 +161,13 @@ Module functions and constants
161161

162162
.. data:: sqlite_version
163163

164-
The version number of the run-time SQLite library, as a string.
164+
Version number of the run-time 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 run-time 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 return any object that fit the application programmers need.
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 accept a :class:`bytes` parameter and return 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 :kbd:`.dump` command in the :program:`sqlite3` shell.
794793

795794
Example::
796795

@@ -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,19 @@ 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` when 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 is when 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, fewer rows are returned.
10201020

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

10261026
.. method:: fetchall()
10271027

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.
1028+
Fetch all (remaining) rows of a query result as a :class:`list`.
1029+
Return an empty list when no rows are available.
1030+
Note that the :attr:`arraysize` attribute can affect the performance of
1031+
this operation.
10311032

10321033
.. method:: close()
10331034

@@ -1054,7 +1055,7 @@ Cursor Objects
10541055

10551056
.. attribute:: lastrowid
10561057

1057-
This read-only attribute provides the row id of the last inserted row. It
1058+
Read-only attribute that provides the row id of the last inserted row. It
10581059
is only updated after successful ``INSERT`` or ``REPLACE`` statements
10591060
using the :meth:`execute` method. For other statements, after
10601061
:meth:`executemany` or :meth:`executescript`, or if the insertion failed,
@@ -1074,16 +1075,16 @@ Cursor Objects
10741075

10751076
.. attribute:: description
10761077

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

10811082
It is set for ``SELECT`` statements without any matching rows as well.
10821083

10831084
.. attribute:: connection
10841085

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

@@ -1111,7 +1112,8 @@ Row Objects
11111112

11121113
.. method:: keys
11131114

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

11171119
.. versionchanged:: 3.5

0 commit comments

Comments
 (0)