]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-100668: Clarify how sqlite3 maps parameters onto placeholders (GH-100960)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 14 Jan 2023 23:04:53 +0000 (15:04 -0800)
committerGitHub <noreply@github.com>
Sat, 14 Jan 2023 23:04:53 +0000 (15:04 -0800)
(cherry picked from commit 206f05a46b426eb374f724f8e7cd42f2f9643bb8)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Doc/library/sqlite3.rst

index 6d0422122a3d476fcb438308ef2f3ad0bb714bcf..c52bdd7ca4acb8084d6d60f03f77f1fd1fa3ffd3 100644 (file)
@@ -1823,15 +1823,18 @@ close the single quote and inject ``OR TRUE`` to select all rows::
 Instead, use the DB-API's parameter substitution. To insert a variable into a
 query string, use a placeholder in the string, and substitute the actual values
 into the query by providing them as a :class:`tuple` of values to the second
-argument of the cursor's :meth:`~Cursor.execute` method. An SQL statement may
-use one of two kinds of placeholders: question marks (qmark style) or named
-placeholders (named style). For the qmark style, ``parameters`` must be a
-:term:`sequence <sequence>`. For the named style, it can be either a
-:term:`sequence <sequence>` or :class:`dict` instance. The length of the
-:term:`sequence <sequence>` must match the number of placeholders, or a
-:exc:`ProgrammingError` is raised. If a :class:`dict` is given, it must contain
-keys for all named parameters. Any extra items are ignored. Here's an example of
-both styles:
+argument of the cursor's :meth:`~Cursor.execute` method.
+
+An SQL statement may use one of two kinds of placeholders:
+question marks (qmark style) or named placeholders (named style).
+For the qmark style, *parameters* must be a
+:term:`sequence` whose length must match the number of placeholders,
+or a :exc:`ProgrammingError` is raised.
+For the named style, *parameters* should be
+an instance of a :class:`dict` (or a subclass),
+which must contain keys for all named parameters;
+any extra items are ignored.
+Here's an example of both styles:
 
 .. testcode::
 
@@ -1858,6 +1861,11 @@ both styles:
 
    [('C', 1972)]
 
+.. note::
+
+   :pep:`249` numeric placeholders are *not* supported.
+   If used, they will be interpreted as named placeholders.
+
 
 .. _sqlite3-adapters: