This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: [sqlite3] early exit for non-DML statements in executemany()
Type: enhancement Stage: resolved
Components: Extension Modules Versions:
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, erlendaasland, serhiy.storchaka
Priority: low Keywords: patch

Created on 2021-08-20 20:07 by erlendaasland, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 27865 merged erlendaasland, 2021-08-20 20:09
Messages (2)
msg399992 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-08-20 20:07
Currently, if a non-DML statement is executed with executemany(), we only bail as late as possible: just before the call to _pysqlite_fetch_one_row(). This means that we've already stepped through the statement once (!), and possibly bound values, built the row cast map, and created the description tuple, all before raising the "executemany() can only execute DML statements."

So, the error message currently is not quite true, because we already executed the statement once.

Checking for this earlier will prevent a (possibly time-consuming) sqlite3_step(), and it will leave the main loop in _pysqlite_query_execute() slightly easier to read, IMO.
msg400040 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-08-21 18:59
New changeset 878e7267016ba25d05d8736349fb897c756f311d by Erlend Egeberg Aasland in branch 'main':
bpo-44965: Early exit for non-DML statements in sqlite3.Cursor.executemany() (GH-27865)
Date User Action Args
2022-04-11 14:59:49adminsetgithub: 89128
2021-08-21 18:59:09pablogsalsetstatus: open -> closed
nosy: - pablogsal

resolution: fixed
stage: patch review -> resolved
2021-08-21 18:59:02pablogsalsetnosy: + pablogsal
messages: + msg400040
2021-08-20 20:09:07erlendaaslandsetkeywords: + patch
stage: patch review
pull_requests: + pull_request26320
2021-08-20 20:07:27erlendaaslandcreate