Skip to content

Commit

Permalink
Trying to execute more than one statement with execute() or throwing …
Browse files Browse the repository at this point in the history
…anything

other than string or unicode as the first parameter to execute() now raises a
ProgrammingError instead of a Warning. This makes much more sense.
  • Loading branch information
ghaering committed Aug 5, 2010
1 parent e483c36 commit 35f5d46
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/test/dbapi.py
Expand Up @@ -164,8 +164,8 @@ def CheckExecuteIllegalSql(self):
def CheckExecuteTooMuchSql(self):
try:
self.cu.execute("select 5+4; select 4+5")
self.fail("should have raised a Warning")
except sqlite.Warning:
self.fail("should have raised a ProgrammingError")
except sqlite.ProgrammingError:
return
except:
self.fail("raised wrong exception")
Expand Down
4 changes: 2 additions & 2 deletions src/connection.c
Expand Up @@ -1201,9 +1201,9 @@ PyObject* pysqlite_connection_call(pysqlite_Connection* self, PyObject* args, Py

if (rc != SQLITE_OK) {
if (rc == PYSQLITE_TOO_MUCH_SQL) {
PyErr_SetString(pysqlite_Warning, "You can only execute one statement at a time.");
PyErr_SetString(pysqlite_ProgrammingError, "You can only execute one statement at a time.");
} else if (rc == PYSQLITE_SQL_WRONG_TYPE) {
PyErr_SetString(pysqlite_Warning, "SQL is of wrong type. Must be string or unicode.");
PyErr_SetString(pysqlite_ProgrammingError, "SQL is of wrong type. Must be string or unicode.");
} else {
(void)pysqlite_statement_reset(statement);
_pysqlite_seterror(self->db, NULL);
Expand Down

0 comments on commit 35f5d46

Please sign in to comment.