sqlite3, OperationalError: no such column, shouldn't that ne a ProgrammingError?
Gerhard Häring
gh at ghaering.de
Fri Jun 19 06:20:16 EDT 2009
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() at
http://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.
-- Gerhard
More information about the Python-list
mailing list