Skip to content

Commit b2aa759

Browse files
committed
sqlite3: Reliably detect data query vs modification SQL statements.
1 parent 98bb48b commit b2aa759

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sqlite3/sqlite3.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ def execute(self, sql, params=None):
8989
self.num_cols = sqlite3_column_count(self.stmnt)
9090
print("num_cols", self.num_cols)
9191
# If it's not select, actually execute it here
92-
if not sql.startswith("SELECT"):
93-
self.fetchone()
92+
# num_cols == 0 for statements which don't return data (=> modify it)
93+
if not self.num_cols:
94+
v = self.fetchone()
95+
assert v is None
9496

9597
def close(self):
9698
s = sqlite3_finalize(self.stmnt)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy