On Jun 19, 8:20 pm, Gerhard Häring <[email protected]> wrote: > Gabriel Rossetti wrote: > > Hello everyone, > > > I get an OperationalError with sqlite3 if I put the wrong column name, > > but shouldn't that be a ProgrammingError instead? I read PEP 249 and it > > says : > > > " OperationalError > > Exception raised for errors that are related to the > > database's operation and not necessarily under the control > > of the programmer, e.g. an unexpected disconnect occurs, > > the data source name is not found, a transaction could not > > be processed, a memory allocation error occurred during > > processing, etc. It must be a subclass of DatabaseError. > > ProgrammingError > > Exception raised for programming errors, e.g. table not > > found or already exists, syntax error in the SQL > > statement, wrong number of parameters specified, etc. It > > must be a subclass of DatabaseError. > > " > > > and to me it sounds more like a programming error than an operational > > error. > > I agree. But I can't help you there. > > See _pysqlite_seterror() > athttp://oss.itsystementwicklung.de/trac/pysqlite/browser/src/util.c > > What I do is map SQLite error codes to DB-API exceptions. And SQLite > reports your error as generic SQLITE_ERROR, which is mapped to > OperationalError.
Hi Gerhard, In http://www.sqlite.org/c3ref/prepare.html it says """When an error occurs, sqlite3_step() will return one of the detailed error codes or extended error codes. The legacy behavior was that sqlite3_step() would only return a generic SQLITE_ERROR result code and you would have to make a second call to sqlite3_reset() in order to find the underlying cause of the problem. With the "v2" prepare interfaces, the underlying reason for the error is returned immediately.""" Are you using sqlite3_prepare() or sqlite3_prepare_v2()? sqlite3_errcode() or sqlite3_extended_errcode()? Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
