Skip to content

Commit e85897a

Browse files
author
Erlend E. Aasland
committed
bpo-45608: Document missing DB-API attributes
1 parent 51ed2c5 commit e85897a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Doc/library/sqlite3.rst

Lines changed: 38 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` 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

0 commit comments

Comments
 (0)