You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document that sqlite3.Cursor.executescript disregards isolation_level #74778
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.
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;".
changed the title [-]sqlite3 executescript does not respect isolation_level?[/-][+]Document that sqlite3.Cursor.executescript disregards isolation_level[/+]on May 18, 2021
Activity
NoahLevitt commentedon Jun 7, 2017
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.
jimjjewett commentedon Jun 9, 2017
Do you have a test case that could be used to verify a patch?
(Or even a full patch?)
NoahLevitt commentedon Jun 12, 2017
Here's a test case
NoahLevitt commentedon Jun 12, 2017
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;".
erlend-aasland commentedon May 18, 2021
Mentioning this behaviour in the documentation should be sufficient.
[-]sqlite3 executescript does not respect isolation_level?[/-][+]Document that sqlite3.Cursor.executescript disregards isolation_level[/+]berkerpeksag commentedon May 19, 2021
New changeset 76ed53c by Miss Islington (bot) in branch '3.9':
bpo-30593: Doc'ed that executescript() disregards isolation level (GH-26220)
76ed53c
berkerpeksag commentedon May 19, 2021
New changeset 1f483c0 by Miss Islington (bot) in branch '3.10':
bpo-30593: Doc'ed that executescript() disregards isolation level (GH-26220)
1f483c0