8000 Docs: use parameter list for sqlite3.Cursor.execute* (GH-101782) · python/cpython@18313ec · GitHub
[go: up one dir, main page]

Skip to content

Commit 18313ec

Browse files
miss-islingtonerlend-aaslandAlexWaygood
authored
Docs: use parameter list for sqlite3.Cursor.execute* (GH-101782)
(cherry picked from commit 2037ebf) Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
1 parent 7ca9da9 commit 18313ec

File tree

1 file changed

+33
-12
lines changed

1 file changed

+33
-12
lines changed

Doc/library/sqlite3.rst

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,30 +1335,51 @@ Cursor objects
13351335

13361336
.. method:: execute(sql, parameters=(), /)
13371337

1338-
Execute SQL statement *sql*.
1339-
Bind values to the statement using :ref:`placeholders
1340-
<sqlite3-placeholders>` that map to the :term:`sequence` or :class:`dict`
1341-
*parameters*.
1338+
Execute SQL a single SQL statement,
1339+
optionally binding Python values using
1340+
:ref:`placeholders <sqlite3-placeholders>`.
13421341

1343-
:meth:`execute` will only execute a single SQL statement. If you try to execute
1344-
more than one statement with it, it will raise a :exc:`ProgrammingError`. Use
1345-
:meth:`executescript` if you want to execute multiple SQL statements with one
1346-
call.
1342+
:param str sql:
1343+
A single SQL statement.
1344+
1345+
:param parameters:
1346+
Python values to bind to placeholders in *sql*.
1347+
A :class:`!dict` if named placeholders are used.
1348+
A :term:`!sequence` if unnamed placeholders are used.
1349+
See :ref:`sqlite3-placeholders`.
1350+
:type parameters: :class:`dict` | :term:`sequence`
1351+
1352+
:raises ProgrammingError:
1353+
If *sql* contains more than one SQL statement.
13471354

13481355
If :attr:`~Connection.isolation_level` is not ``None``,
13491356
*sql* is an ``INSERT``, ``UPDATE``, ``DELETE``, or ``REPLACE`` statement,
13501357
and there is no open transaction,
13511358
a transaction is implicitly opened before executing *sql*.
13521359

1360+
Use :meth:`executescript` to execute multiple SQL statements.
13531361

13541362
.. method:: executemany(sql, parameters, /)
13551363

1356-
Execute :ref:`parameterized <sqlite3-placeholders>` SQL statement *sql*
1357-
against all parameter sequences or mappings found in the sequence
1358-
*parameters*. It is also possible to use an
1359-
:term:`iterator` yielding parameters instead of a sequence.
1364+
For every item in *parameters*,
1365+
repeatedly execute the :ref:`parameterized <sqlite3-placeholders>`
1366+
SQL statement *sql*.
1367+
13601368
Uses the same implicit transaction handling as :meth:`~Cursor.execute`.
13611369

1370+
:param str sql:
1371+
A single SQL :abbr:`DML (Data Manipulation Language)` statement.
1372+
1373+
:param parameters:
1374+
An :term:`!iterable` of parameters to bind with
1375+
the placeholders in *sql*.
1376+
See :ref:`sqlite3-placeholders`.
1377+
:type parameters: :term:`iterable`
1378+
1379+
:raises ProgrammingError:
1380+
If *sql* contains more than one SQL statement,
1381+
or is not a DML statment.
1382+
13621383
Example:
13631384

13641385
.. testcode:: sqlite3.cursor

0 commit comments

Comments
 (0)
0