Skip to content

Commit ebd50d6

Browse files
committed
Documented support for named paramstyle in sqlite3.
The documentation for `sqlite3.paramstyle` states that only `qmark` and `numeric` styles are supported for parameter placeholders but, according to the SQLite documentation, the `named` style is also supported. See the following links for more details: - https://docs.python.org/3/library/sqlite3.html#sqlite3.paramstyle - https://peps.python.org/pep-0249/#paramstyle - https://www.sqlite.org/lang_expr.html#parameters A simple example confirms that this is supported: ```pycon >>> import sqlite3 >>> con = sqlite3.connect(":memory:") >>> cur = con.execute("CREATE TEMPORARY TABLE t (name TEXT)") >>> cur.execute("INSERT INTO t (name) VALUES ('Bob'), ('Cat'), ('Joe')") <sqlite3.Cursor object at 0x7fcbe373b940> >>> cur.execute("SELECT * FROM t WHERE name = :name", {"name": "Cat"}) <sqlite3.Cursor object at 0x7fcbe373b940> >>> print(cur.fetchone()[0]) Cat ```
1 parent 0ee59a9 commit ebd50d6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Doc/library/sqlite3.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,9 @@ Module constants
478478

479479
.. note::
480480

481-
The :mod:`!sqlite3` module supports both ``qmark`` and ``numeric`` DB-API
482-
parameter styles, because that is what the underlying SQLite library
483-
supports. However, the DB-API does not allow multiple values for
481+
The :mod:`!sqlite3` module supports ``qmark``, ``numeric``, and ``named``
482+
DB-API parameter styles, because that is what the underlying SQLite
483+
library supports. However, the DB-API does not allow multiple values for
484484
the ``paramstyle`` attribute.
485485

486486
.. data:: sqlite_version

0 commit comments

Comments
 (0)