Skip to content

Commit 020aa06

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

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
@@ -116,6 +116,24 @@ Module functions and constants
116116
------------------------------
117117

118118

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

121139
The version number of this module, as a string. This is not the version of
@@ -138,6 +156,26 @@ Module functions and constants
138156
The version number of the run-time SQLite library, as a tuple of integers.
139157

140158

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

143181
This constant is meant to be used with the *detect_types* parameter of the
@@ -688,6 +726,14 @@ Cursor Objects
688726
The cursor will be unusable from this point forward; a :exc:`ProgrammingError`
689727
exception will be raised if any operation is attempted with the cursor.
690728

729+
.. method:: setinputsizes(sizes)
730+
731+
Required by the DB-API. Is a no-op in :mod:`sqlite3`.
732+
733+
.. method:: setoutputsize(size [, column])
734+
735+
Required by the DB-API. Is a no-op in :mod:`sqlite3`.
736+
691737
.. attribute:: rowcount
692738

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

0 commit comments

Comments
 (0)