From 5236ee9558c28852ac61f413e649e95ac6738477 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Mon, 30 Nov 2026 18:57:34 +0900 Subject: [PATCH] Doc: Correct sqlite3 API descriptions and SQL examples (GH-162193) (cherry picked from commit 6ffa102ad71dc70be5ff349dc26770632325bb4c) Co-authored-by: Inada Naoki --- Doc/library/sqlite3.rst | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 8e022e1b31d0f3b..0796e0ce0ed4a8a 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -448,9 +448,9 @@ Module constants .. code-block:: sql CREATE TABLE test( - i integer primary key, ! will look up a converter named "integer" - p point, ! will look up a converter named "point" - n number(10) ! will look up a converter named "number" + i integer primary key, -- will look up a converter named "integer" + p point, -- will look up a converter named "point" + n number(10) -- will look up a converter named "number" ) This flag may be combined with :const:`PARSE_COLNAMES` using the ``|`` @@ -458,8 +458,9 @@ Module constants .. note:: - Generated fields (for example ``MAX(p)``) are returned as :class:`str`. - Use :const:`!PARSE_COLNAMES` to enforce types for such queries. + Expressions such as ``MAX(p)`` have no declared type, so their results use + the :ref:`default type conversions `. + Use :const:`!PARSE_COLNAMES` to specify a converter for such expressions. .. data:: PARSE_COLNAMES @@ -472,7 +473,7 @@ Module constants .. code-block:: sql - SELECT MAX(p) as "p [point]" FROM test; ! will look up converter "point" + SELECT MAX(p) as "p [point]" FROM test; -- will look up converter "point" This flag may be combined with :const:`PARSE_DECLTYPES` using the ``|`` (bitwise or) operator. @@ -820,7 +821,7 @@ Connection objects * ``finalize()``: Return the final result of the aggregate as :ref:`a type natively supported by SQLite `. - The number of arguments that the ``step()`` and ``value()`` methods + The number of arguments that the ``step()`` and ``inverse()`` methods must accept is controlled by *num_params*. Set to ``None`` to remove an existing SQL aggregate window function. @@ -1163,8 +1164,8 @@ Connection objects ``ATTACH DATABASE`` SQL statement. :param float sleep: - The number of seconds to sleep between successive attempts - to back up remaining pages. + The number of seconds to wait before retrying a backup step + when the database is busy or locked. Example 1, copy an existing database into another: @@ -1384,8 +1385,7 @@ Connection objects This read-only attribute corresponds to the low-level SQLite `autocommit mode`_. - ``True`` if a transaction is active (there are uncommitted changes), - ``False`` otherwise. + ``True`` if a transaction is active, ``False`` otherwise. .. versionadded:: 3.2 @@ -2145,7 +2145,7 @@ The coordinate pair will be stored as a text string in the database, using a semicolon to separate the coordinates. This can be implemented by adding a ``__conform__(self, protocol)`` method which returns the adapted value. -The object passed to *protocol* will be of type :class:`PrepareProtocol`. +The parameter *protocol* will be :class:`PrepareProtocol`. .. testcode:: @@ -2416,7 +2416,7 @@ or if :attr:`~Connection.autocommit` is ``True``, the context manager does nothing. .. note:: - The context manager neither implicitly opens a new transaction + The context manager neither implicitly opens a new transaction on entry nor closes the connection. If you need a closing context manager, consider using :meth:`contextlib.closing`. @@ -2464,8 +2464,8 @@ Some useful URI tricks include: OperationalError: attempt to write a readonly database >>> con.close() -* Do not implicitly create a new database file if it does not already exist; - will raise :exc:`~sqlite3.OperationalError` if unable to create a new file: +* Open an existing database in read/write mode. + If the file does not exist, :func:`connect` raises :exc:`OperationalError`: .. doctest::