classification
Title: Document that sqlite3.Cursor.executescript disregards isolation_level
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Jim.Jewett, Noah Levitt, berker.peksag, docs@python, erlendaasland, miss-islington, palaviv
Priority: normal Keywords: patch

Created on 2017-06-07 22:26 by Noah Levitt, last changed 2021-05-19 07:40 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
issue30593-fix.diff Noah Levitt, 2017-06-12 19:33
issue30593-test.diff Noah Levitt, 2017-06-12 19:35 review
Pull Requests
URL Status Linked Edit
PR 26220 merged erlendaasland, 2021-05-18 22:12
PR 26230 merged miss-islington, 2021-05-19 07:05
PR 26231 merged miss-islington, 2021-05-19 07:06
Messages (7)
msg295376 - (view) Author: Noah Levitt (Noah Levitt) Date: 2017-06-07 22:26
As far as I can tell, sqlite3 executescript() does not respect isolation_level. Is that true? If so, I think it's worth mentioning in the doc. Or maybe it should respect isolation_level, not sure there's any particular reason not to.
msg295567 - (view) Author: Jim Jewett (Jim.Jewett) * (Python triager) Date: 2017-06-09 20:33
Do you have a test case that could be used to verify a patch?
(Or even a full patch?)
msg295813 - (view) Author: Noah Levitt (Noah Levitt) Date: 2017-06-12 19:25
Here's a test case
msg295815 - (view) Author: Noah Levitt (Noah Levitt) Date: 2017-06-12 19:33
And here's a fix.

Unfortunately I think the change could break people's scripts. If they have isolation_level set (not None) and use executescript(), they will have to issue an explicit call to connection.commit().

executescript() could do the commit itself explicitly after running the sql, I suppose. Then the behavior is much like the old behavior, but at least you get the performance boost of running inside a transaction. (Substantial if you pass 10k insert statements to executescript(), or something like that.)

Or, we could not change the code, and instead change the documentation. The docs could suggest wrapping the sql script with "begin;" and "commit;".
msg393908 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-05-18 22:03
Mentioning this behaviour in the documentation should be sufficient.
msg393928 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2021-05-19 07:32
New changeset 76ed53ca7bf0d4a43099d9401af5fe9f75689885 by Miss Islington (bot) in branch '3.9':
bpo-30593: Doc'ed that executescript() disregards isolation level (GH-26220)
https://github.com/python/cpython/commit/76ed53ca7bf0d4a43099d9401af5fe9f75689885
msg393929 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2021-05-19 07:37
New changeset 1f483c0c1b5a9fd1062bacc2aeba6bb0e00009b7 by Miss Islington (bot) in branch '3.10':
bpo-30593: Doc'ed that executescript() disregards isolation level (GH-26220)
https://github.com/python/cpython/commit/1f483c0c1b5a9fd1062bacc2aeba6bb0e00009b7
History
Date User Action Args
2021-05-19 07:40:30berker.peksagsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-05-19 07:37:39berker.peksagsetmessages: + msg393929
2021-05-19 07:32:48berker.peksagsetmessages: + msg393928
2021-05-19 07:06:02miss-islingtonsetpull_requests: + pull_request24848
2021-05-19 07:05:57miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request24847
2021-05-18 22:32:22erlendaaslandsettitle: sqlite3 executescript does not respect isolation_level? -> Document that sqlite3.Cursor.executescript disregards isolation_level
2021-05-18 22:12:42erlendaaslandsetstage: needs patch -> patch review
pull_requests: + pull_request24837
2021-05-18 22:03:22erlendaaslandsetversions: + Python 3.9, Python 3.10, Python 3.11, - Python 2.7, Python 3.4, Python 3.5, Python 3.6
nosy: + erlendaasland, berker.peksag, docs@python

messages: + msg393908

assignee: docs@python
components: + Documentation, - Library (Lib)
2017-06-13 15:51:50palavivsetnosy: + palaviv
2017-06-12 19:35:33Noah Levittsetfiles: + issue30593-test.diff
2017-06-12 19:33:04Noah Levittsetfiles: + issue30593-fix.diff
keywords: + patch
messages: + msg295815
2017-06-12 19:25:39Noah Levittsetmessages: + msg295813
2017-06-09 20:33:02Jim.Jewettsetnosy: + Jim.Jewett
messages: + msg295567

type: behavior
stage: needs patch
2017-06-07 22:26:12Noah Levittcreate