Repository navigation
Document that sqlite3.Cursor.executescript disregards isolation_level #74778
Description
Activity
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.
- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on Jun 7, 2017 Do you have a test case that could be used to verify a patch?
(Or even a full patch?)- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Jun 9, 2017 Here's a test case
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;".
Mentioning this behaviour in the documentation should be sufficient.
- addeddocsDocumentation in the Doc dirDocumentation in the Doc dir3.9 (EOL)end of lifeend of life3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixesand removedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on May 18, 2021 - changed the title
[-]sqlite3 executescript does not respect isolation_level?[/-][+]Document that sqlite3.Cursor.executescript disregards isolation_level[/+]on May 18, 2021
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: