[issue22382] sqlite3 connection built from apsw connection should raise IntegrityError, not DatabaseError

william tonkin report at bugs.python.org
Thu Sep 11 16:43:46 CEST 2014


william tonkin added the comment:

sqlite3 allows a connection to be built from an apsw.Connection().  Using an apsw.Connection() to build an sqlite3.connect() implies that the underlying sqlite database engine will have extended error codes turned on (the default if for them to be turned off.)

The problem is that Modules/_sqlite/util.c:_pysqlite_seterror() is not extended error code aware.  In particular, the extended error code SQLITE_CONSTRAINT_CHECK will not be recognized as a kind of constraint violation and will fall into the "default:" arm of the case statement.  This will result in raising the exception DatabaseError when the correct exception to raise is IntegrityError.

One simple solution would be to convert the extended error code back to the base error code, that is:
 "errorcode = 0xffu % sqlite3_errcode(db);"

----------
status: closed -> open
type:  -> behavior

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22382>
_______________________________________


More information about the Python-bugs-list mailing list