classification
Title: sqlite3 executescript does not respect isolation_level?
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Jim.Jewett, Noah Levitt, palaviv
Priority: normal Keywords: patch

Created on 2017-06-07 22:26 by Noah Levitt, last changed 2017-06-13 15:51 by palaviv.

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
Messages (4)
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;".
History
Date User Action Args
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