summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend.aasland@protonmail.com>2023-02-10 21:21:20 (GMT)
committerGitHub <noreply@github.com>2023-02-10 21:21:20 (GMT)
commita565cd5b10bcb676dfb623a1a209be76e7fbecf3 (patch)
tree30b3dc3b2c672d6bc9f75e19e61abbc681cde3e1 /Doc
parent6d8ef9680689823229106c22aa74e1c549a250ec (diff)
downloadcpython-a565cd5b10bcb676dfb623a1a209be76e7fbecf3.zip
cpython-a565cd5b10bcb676dfb623a1a209be76e7fbecf3.tar.gz
cpython-a565cd5b10bcb676dfb623a1a209be76e7fbecf3.tar.bz2
[3.10] Docs: use parameter list for sqlite3.Cursor.execute* (GH-101782) (#101808)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> (cherry picked from commit 2037ebf81bd4bbe5421421b822bd57cfd665a1e9)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/sqlite3.rst47
1 files changed, 35 insertions, 12 deletions
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst
index 3a69254..dc8a48b 100644
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -1044,30 +1044,53 @@ Cursor objects
.. method:: execute(sql, parameters=(), /)
- Execute SQL statement *sql*.
- Bind values to the statement using :ref:`placeholders
- <sqlite3-placeholders>` that map to the :term:`sequence` or :class:`dict`
- *parameters*.
+ Execute SQL a single SQL statement,
+ optionally binding Python values using
+ :ref:`placeholders <sqlite3-placeholders>`.
- :meth:`execute` will only execute a single SQL statement. If you try to execute
- more than one statement with it, it will raise a :exc:`Warning`. Use
- :meth:`executescript` if you want to execute multiple SQL statements with one
- call.
+ :param str sql:
+ A single SQL statement.
+
+ :param parameters:
+ Python values to bind to placeholders in *sql*.
+ A :class:`!dict` if named placeholders are used.
+ A :term:`!sequence` if unnamed placeholders are used.
+ See :ref:`sqlite3-placeholders`.
+ :type parameters: :class:`dict` | :term:`sequence`
+
+ :raises Warning:
+ If *sql* contains more than one SQL statement.
If :attr:`~Connection.isolation_level` is not ``None``,
*sql* is an ``INSERT``, ``UPDATE``, ``DELETE``, or ``REPLACE`` statement,
and there is no open transaction,
a transaction is implicitly opened before executing *sql*.
+ Use :meth:`executescript` to execute multiple SQL statements.
.. method:: executemany(sql, parameters, /)
- Execute :ref:`parameterized <sqlite3-placeholders>` SQL statement *sql*
- against all parameter sequences or mappings found in the sequence
- *parameters*. It is also possible to use an
- :term:`iterator` yielding parameters instead of a sequence.
+ For every item in *parameters*,
+ repeatedly execute the :ref:`parameterized <sqlite3-placeholders>`
+ SQL statement *sql*.
+
Uses the same implicit transaction handling as :meth:`~Cursor.execute`.
+ :param str sql:
+ A single SQL :abbr:`DML (Data Manipulation Language)` statement.
+
+ :param parameters:
+ An :term:`!iterable` of parameters to bind with
+ the placeholders in *sql*.
+ See :ref:`sqlite3-placeholders`.
+ :type parameters: :term:`iterable`
+
+ :raises ProgrammingError:
+ If *sql* is not a DML statment.
+
+ :raises Warning:
+ If *sql* contains more than one SQL statement.
+
Example:
.. testcode:: sqlite3.cursor