Skip to content

Commit 1d88b2b

Browse files
miss-islingtonErlend Egeberg Aasland
and
Erlend Egeberg Aasland
authored
bpo-45608: Document missing sqlite3 DB-API attributes and methods (GH-29219) (GH-29281)
(cherry picked from commit 88d8a1a) Co-authored-by: Erlend Egeberg Aasland <[email protected]>
1 parent 9e00121 commit 1d88b2b

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

Doc/library/sqlite3.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,24 @@ Module functions and constants
117117
------------------------------
118118

119119

120+
.. data:: apilevel
121+
122+
String constant stating the supported DB-API level. Required by the DB-API.
123+
Hard-coded to ``"2.0"``.
124+
125+
.. data:: paramstyle
126+
127+
String constant stating the type of parameter marker formatting expected by
128+
the :mod:`sqlite3` module. Required by the DB-API. Hard-coded to
129+
``"qmark"``.
130+
131+
.. note::
132+
133+
The :mod:`sqlite3` module supports both ``qmark`` and ``numeric`` DB-API
134+
parameter styles, because that is what the underlying SQLite library
135+
supports. However, the DB-API does not allow multiple values for
136+
the ``paramstyle`` attribute.
137+
120138
.. data:: version
121139

122140
The version number of this module, as a string. This is not the version of
@@ -139,6 +157,26 @@ Module functions and constants
139157
The version number of the run-time SQLite library, as a tuple of integers.
140158

141159

160+
.. data:: threadsafety
161+
162+
Integer constant required by the DB-API, stating the level of thread safety
163+
the :mod:`sqlite3` module supports. Currently hard-coded to ``1``, meaning
164+
*"Threads may share the module, but not connections."* However, this may not
165+
always be true. You can check the underlying SQLite library's compile-time
166+
threaded mode using the following query::
167+
168+
import sqlite3
169+
con = sqlite3.connect(":memory:")
170+
con.execute("""
171+
select * from pragma_compile_options
172+
where compile_options like 'THREADSAFE=%'
173+
""").fetchall()
174+
175+
Note that the `SQLITE_THREADSAFE levels
176+
<https://sqlite.org/compile.html#threadsafe>`_ do not match the DB-API 2.0
177+
``threadsafety`` levels.
178+
179+
142180
.. data:: PARSE_DECLTYPES
143181

144182
This constant is meant to be used with the *detect_types* parameter of the
@@ -701,6 +739,14 @@ Cursor Objects
701739
The cursor will be unusable from this point forward; a :exc:`ProgrammingError`
702740
exception will be raised if any operation is attempted with the cursor.
703741

742+
.. method:: setinputsizes(sizes)
743+
744+
Required by the DB-API. Is a no-op in :mod:`sqlite3`.
745+
746+
.. method:: setoutputsize(size [, column])
747+
748+
Required by the DB-API. Is a no-op in :mod:`sqlite3`.
749+
704750
.. attribute:: rowcount
705751

706752
Although the :class:`Cursor` class of the :mod:`sqlite3` module implements this

0 commit comments

Comments
 (0)