Skip to content

Commit 1e6ceaf

Browse files
[3.10] pythongh-95273: Improve documented return values and exceptions raised for sqlite3 class methods (pythonGH-95530)
Co-authored-by: Ezio Melotti <[email protected]> Co-authored-by: Alex Waygood <[email protected]>. (cherry picked from commit 12d92c7) Co-authored-by: Erlend Egeberg Aasland <[email protected]>
1 parent f6b1c5e commit 1e6ceaf

File tree

1 file changed

+18
-33
lines changed

1 file changed

+18
-33
lines changed

Doc/library/sqlite3.rst

+18-33
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,14 @@ Module functions and constants
267267
in RAM instead of on disk.
268268
:type database: :term:`path-like object`
269269

270-
:param timeout:
270+
:param float timeout:
271271
How many seconds the connection should wait before raising
272272
an exception, if the database is locked by another connection.
273273
If another connection opens a transaction to modify the database,
274274
it will be locked until that transaction is committed.
275275
Default five seconds.
276-
:type timeout: float
277276

278-
:param detect_types:
277+
:param int detect_types:
279278
Control whether and how data types not
280279
:ref:`natively supported by SQLite <sqlite3-types>`
281280
are looked up to be converted to Python types,
@@ -288,7 +287,6 @@ Module functions and constants
288287
even when the *detect_types* parameter is set; :class:`str` will be
289288
returned instead.
290289
By default (``0``), type detection is disabled.
291-
:type detect_types: int
292290

293291
:param isolation_level:
294292
The :attr:`~Connection.isolation_level` of the connection,
@@ -298,33 +296,29 @@ Module functions and constants
298296
See :ref:`sqlite3-controlling-transactions` for more.
299297
:type isolation_level: str | None
300298

301-
:param check_same_thread:
299+
:param bool check_same_thread:
302300
If ``True`` (default), only the creating thread may use the connection.
303301
If ``False``, the connection may be shared across multiple threads;
304302
if so, write operations should be serialized by the user to avoid data
305303
corruption.
306-
:type check_same_thread: bool
307304

308-
:param factory:
305+
:param Connection factory:
309306
A custom subclass of :class:`Connection` to create the connection with,
310307
if not the default :class:`Connection` class.
311-
:type factory: :class:`Connection`
312308

313-
:param cached_statements:
309+
:param int cached_statements:
314310
The number of statements that ``sqlite3``
315311
should internally cache for this connection, to avoid parsing overhead.
316312
By default, 100 statements.
317-
:type cached_statements: int
318313

319-
:param uri:
314+
:param bool uri:
320315
If set to ``True``, *database* is interpreted as a
321316
:abbr:`URI (Uniform Resource Identifier)` with a file path
322317
and an optional query string.
323318
The scheme part *must* be ``"file:"``,
324319
and the path can be relative or absolute.
325320
The query string allows passing parameters to SQLite,
326321
enabling various :ref:`sqlite3-uri-tricks`.
327-
:type uri: bool
328322

329323
:rtype: Connection
330324

@@ -475,14 +469,12 @@ Connection objects
475469

476470
Create or remove a user-defined SQL function.
477471

478-
:param name:
472+
:param str name:
479473
The name of the SQL function.
480-
:type name: str
481474

482-
:param narg:
475+
:param int narg:
483476
The number of arguments the SQL function can accept.
484477
If ``-1``, it may take any number of arguments.
485-
:type narg: int
486478

487479
:param func:
488480
A callable that is called when the SQL function is invoked.
@@ -491,11 +483,10 @@ Connection objects
491483
Set to ``None`` to remove an existing SQL function.
492484
:type func: :term:`callback` | None
493485

494-
:param deterministic:
486+
:param bool deterministic:
495487
If ``True``, the created SQL function is marked as
496488
`deterministic <https://sqlite.org/deterministic.html>`_,
497489
which allows SQLite to perform additional optimizations.
498-
:type deterministic: bool
499490

500491
:raises NotSupportedError:
501492
If *deterministic* is used with SQLite versions older than 3.8.3.
@@ -512,14 +503,12 @@ Connection objects
512503

513504
Create or remove a user-defined SQL aggregate function.
514505

515-
:param name:
506+
:param str name:
516507
The name of the SQL aggregate function.
517-
:type name: str
518508

519-
:param n_arg:
509+
:param int n_arg:
520510
The number of arguments the SQL aggregate function can accept.
521511
If ``-1``, it may take any number of arguments.
522-
:type n_arg: int
523512

524513
:param aggregate_class:
525514
A class must implement the following methods:
@@ -727,16 +716,14 @@ Connection objects
727716
Works even if the database is being accessed by other clients
728717
or concurrently by the same connection.
729718

730-
:param target:
719+
:param Connection target:
731720
The database connection to save the backup to.
732-
:type target: Connection
733721

734-
:param pages:
722+
:param int pages:
735723
The number of pages to copy at a time.
736724
If equal to or less than ``0``,
737725
the entire database is copied in a single step.
738726
Defaults to ``-1``.
739-
:type pages: int
740727

741728
:param progress:
742729
If set to a callable, it is invoked with three integer arguments for
@@ -747,18 +734,16 @@ Connection objects
747734
Defaults to ``None``.
748735
:type progress: :term:`callback` | None
749736
750-
:param name:
737+
:param str name:
751738
The name of the database to back up.
752739
Either ``"main"`` (the default) for the main database,
753740
``"temp"`` for the temporary database,
754741
or the name of a custom database as attached using the
755742
``ATTACH DATABASE`` SQL statement.
756-
:type name: str
757743

758-
:param sleep:
744+
:param float sleep:
759745
The number of seconds to sleep between successive attempts
760746
to back up remaining pages.
761-
:type sleep: float
762747

763748
Example 1, copy an existing database into another::
764749

@@ -872,13 +857,13 @@ Cursor objects
872857

873858
.. method:: fetchone()
874859

875-
Fetch the next row of a query result set as a :class:`tuple`.
860+
Return the next row of a query result set as a :class:`tuple`.
876861
Return ``None`` if no more data is available.
877862

878863

879864
.. method:: fetchmany(size=cursor.arraysize)
880865

881-
Fetch the next set of rows of a query result as a :class:`list`.
866+
Return the next set of rows of a query result as a :class:`list`.
882867
Return an empty list if no more rows are available.
883868

884869
The number of rows to fetch per call is specified by the *size* parameter.
@@ -894,7 +879,7 @@ Cursor objects
894879

895880
.. method:: fetchall()
896881

897-
Fetch all (remaining) rows of a query result as a :class:`list`.
882+
Return all (remaining) rows of a query result as a :class:`list`.
898883
Return an empty list if no rows are available.
899884
Note that the :attr:`arraysize` attribute can affect the performance of
900885
this operation.

0 commit comments

Comments
 (0)