Skip to content

Commit 2361908

Browse files
Erlend Egeberg AaslandAlexWaygoodCAM-Gerlach
authored
pythongh-95273: Normalise sqlite3 reference wording (python#95274)
Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: CAM Gerlach <[email protected]>
1 parent 4dd099b commit 2361908

File tree

1 file changed

+48
-45
lines changed

1 file changed

+48
-45
lines changed

Doc/library/sqlite3.rst

+48-45
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ 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
.. deprecated-removed:: 3.12 3.14
156156
This constant used to reflect the version number of the ``pysqlite``
@@ -160,8 +160,8 @@ Module functions and constants
160160

161161
.. data:: version_info
162162

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

166166
.. deprecated-removed:: 3.12 3.14
167167
This constant used to reflect the version number of the ``pysqlite``
@@ -171,12 +171,13 @@ Module functions and constants
171171

172172
.. data:: sqlite_version
173173

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

176176

177177
.. data:: sqlite_version_info
178178

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

181182

182183
.. data:: threadsafety
@@ -379,6 +380,7 @@ Module functions and constants
379380

380381
.. function:: enable_callback_tracebacks(flag, /)
381382

383+
Enable or disable callback tracebacks.
382384
By default you will not get any tracebacks in user-defined functions,
383385
aggregates, converters, authorizer callbacks etc. If you want to debug them,
384386
you can call this function with *flag* set to :const:`True`. Afterwards, you
@@ -438,6 +440,7 @@ Connection Objects
438440

439441
.. method:: cursor(factory=Cursor)
440442

443+
Create and return a :class:`Cursor` object.
441444
The cursor method accepts a single optional parameter *factory*. If
442445
supplied, this must be a callable returning an instance of :class:`Cursor`
443446
or its subclasses.
@@ -648,9 +651,9 @@ Connection Objects
648651

649652
.. method:: interrupt()
650653

651-
You can call this method from a different thread to abort any queries that might
652-
be executing on the connection. The query will then abort and the caller will
653-
get an exception.
654+
Call this method from a different thread to abort any queries that might
655+
be executing on the connection.
656+
Aborted queries will raise an exception.
654657

655658

656659
.. method:: set_authorizer(authorizer_callback)
@@ -755,10 +758,9 @@ Connection Objects
755758

756759
.. attribute:: row_factory
757760

758-
You can change this attribute to a callable that accepts the cursor and the
759-
original row as a tuple and will return the real result row. This way, you can
760-
implement more advanced ways of returning results, such as returning an object
761-
that can also access columns by name.
761+
A callable that accepts two arguments,
762+
a :class:`Cursor` object and the raw row results as a :class:`tuple`,
763+
and returns a custom object representing an SQLite row.
762764

763765
Example:
764766

@@ -776,31 +778,28 @@ Connection Objects
776778
777779
.. attribute:: text_factory
778780

779-
Using this attribute you can control what objects are returned for the ``TEXT``
780-
data type. By default, this attribute is set to :class:`str` and the
781-
:mod:`sqlite3` module will return :class:`str` objects for ``TEXT``.
782-
If you want to return :class:`bytes` instead, you can set it to :class:`bytes`.
781+
A callable that accepts a :class:`bytes` parameter and returns a text
782+
representation of it.
783+
The callable is invoked for SQLite values with the ``TEXT`` data type.
784+
By default, this attribute is set to :class:`str`.
785+
If you want to return ``bytes`` instead, set *text_factory* to ``bytes``.
783786

784-
You can also set it to any other callable that accepts a single bytestring
785-
parameter and returns the resulting object.
786-
787-
See the following example code for illustration:
787+
Example:
788788

789789
.. literalinclude:: ../includes/sqlite3/text_factory.py
790790

791791

792792
.. attribute:: total_changes
793793

794-
Returns the total number of database rows that have been modified, inserted, or
794+
Return the total number of database rows that have been modified, inserted, or
795795
deleted since the database connection was opened.
796796

797797

798798
.. method:: iterdump
799799

800-
Returns an iterator to dump the database in an SQL text format. Useful when
801-
saving an in-memory database for later restoration. This function provides
802-
the same capabilities as the :kbd:`.dump` command in the :program:`sqlite3`
803-
shell.
800+
Return an :term:`iterator` to dump the database as SQL source code.
801+
Useful when saving an in-memory database for later restoration.
802+
Similar to the ``.dump`` command in the :program:`sqlite3` shell.
804803

805804
Example::
806805

@@ -881,7 +880,7 @@ Connection Objects
881880

882881
.. method:: getlimit(category, /)
883882

884-
Get a connection run-time limit. *category* is the limit category to be
883+
Get a connection runtime limit. *category* is the limit category to be
885884
queried.
886885

887886
Example, query the maximum length of an SQL statement::
@@ -896,7 +895,7 @@ Connection Objects
896895

897896
.. method:: setlimit(category, limit, /)
898897

899-
Set a connection run-time limit. *category* is the limit category to be
898+
Set a connection runtime limit. *category* is the limit category to be
900899
set. *limit* is the new limit. If the new limit is a negative number, the
901900
limit is unchanged.
902901

@@ -915,7 +914,7 @@ Connection Objects
915914

916915
.. method:: serialize(*, name="main")
917916

918-
This method serializes a database into a :class:`bytes` object. For an
917+
Serialize a database into a :class:`bytes` object. For an
919918
ordinary on-disk database file, the serialization is just a copy of the
920919
disk file. For an in-memory database or a "temp" database, the
921920
serialization is the same sequence of bytes which would be written to
@@ -934,6 +933,8 @@ Connection Objects
934933

935934
.. method:: deserialize(data, /, *, name="main")
936935

936+
Deserialize a :meth:`serialized <serialize>` database into a
937+
:class:`Connection`.
937938
This method causes the database connection to disconnect from database
938939
*name*, and reopen *name* as an in-memory database based on the
939940
serialization contained in *data*. Deserialization will raise
@@ -1013,20 +1014,20 @@ Cursor Objects
10131014

10141015
.. method:: fetchone()
10151016

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

10191020

10201021
.. method:: fetchmany(size=cursor.arraysize)
10211022

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

10251026
The number of rows to fetch per call is specified by the *size* parameter.
1026-
If it is not given, the cursor's arraysize determines the number of rows
1027-
to be fetched. The method should try to fetch as many rows as indicated by
1028-
the size parameter. If this is not possible due to the specified number of
1029-
rows not being available, fewer rows may be returned.
1027+
If *size* is not given, :attr:`arraysize` determines the number of rows
1028+
to be fetched.
1029+
If fewer than *size* rows are available,
1030+
as many rows as are available are returned.
10301031

10311032
Note there are performance considerations involved with the *size* parameter.
10321033
For optimal performance, it is usually best to use the arraysize attribute.
@@ -1035,9 +1036,10 @@ Cursor Objects
10351036

10361037
.. method:: fetchall()
10371038

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

10421044
.. method:: close()
10431045

@@ -1064,7 +1066,7 @@ Cursor Objects
10641066

10651067
.. attribute:: lastrowid
10661068

1067-
This read-only attribute provides the row id of the last inserted row. It
1069+
Read-only attribute that provides the row id of the last inserted row. It
10681070
is only updated after successful ``INSERT`` or ``REPLACE`` statements
10691071
using the :meth:`execute` method. For other statements, after
10701072
:meth:`executemany` or :meth:`executescript`, or if the insertion failed,
@@ -1084,16 +1086,16 @@ Cursor Objects
10841086

10851087
.. attribute:: description
10861088

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

10911093
It is set for ``SELECT`` statements without any matching rows as well.
10921094

10931095
.. attribute:: connection
10941096

1095-
This read-only attribute provides the SQLite database :class:`Connection`
1096-
used by the :class:`Cursor` object. A :class:`Cursor` object created by
1097+
Read-only attribute that provides the SQLite database :class:`Connection`
1098+
belonging to the cursor. A :class:`Cursor` object created by
10971099
calling :meth:`con.cursor() <Connection.cursor>` will have a
10981100
:attr:`connection` attribute that refers to *con*::
10991101

@@ -1121,7 +1123,8 @@ Row Objects
11211123

11221124
.. method:: keys
11231125

1124-
This method returns a list of column names. Immediately after a query,
1126+
Return a :class:`list` of column names as :class:`strings <str>`.
1127+
Immediately after a query,
11251128
it is the first member of each tuple in :attr:`Cursor.description`.
11261129

11271130
.. versionchanged:: 3.5

0 commit comments

Comments
 (0)