sqlite3, OperationalError: no such column,shouldn't that ne a ProgrammingError?

G

Gabriel Rossetti

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.

Thank you,
Gabriel
 
J

John Machin

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 :
[snip]
and to me it sounds more like a programming error than an operational
error.

How about showing us the code you used and the exact error message and
traceback?
 
J

Jon Clements

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.

Thank you,
Gabriel

I would agree. With v2.5.2 of Python, I'm getting OperationalError
from sqlite3 and ProgrammingError from the psycopg2 (for postgres)
library. (Trying to create a table that already exists, trying to
'create tabel' and trying to select from non-existant tables)

I don't have time to go through code but looking at
http://www.sqlite.org/c3ref/c_abort.html, it would appear that there's
enough error results to distinguish between Operational and
Programming exceptions. Perhaps result != SQLITE_OK raises
OperationalError, or I'm looking at the wrong C spec for the version
in various Python versions etc... Or perhaps there's some chosen
rationale... or, perhaps, for an embedded engine, no one cares how it
failed, it just did...


Jon
 
G

Gabriel Rossetti

John said:
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 :

[snip]

and to me it sounds more like a programming error than an operational
error.

How about showing us the code you used and the exact error message and
traceback?
Well, the code isn't really relevant to the problem, but here is is :

import sqlite3

conn = sqlite3.connect("/tmp/test.db")
conn.execute("SELECT name, value FROM local_param")

for row in conn:
print row

And I get :

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sqlite3.OperationalError: no such table: local_param


Which I think should be a ProgrammingError

If I fix the table name I but use a wrong column name I also get an
OperationalError


import sqlite3

conn = sqlite3.connect("/tmp/test.db")
conn.execute("SELECT name, valueeeeeeee FROM local_parameters")

for row in conn:
print row

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sqlite3.OperationalError: no such column: valueeeeeeee

Which should also be a ProgrammingError as I see it and as my
interpretation of the documention.

Gabriel
 
J

John Machin

John said:
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 :

[snip]

and to me it sounds more like a programming error than an operational
error.

How about showing us the code you used and the exact error message and
traceback?
Well, the code isn't really relevant to the problem, but here is is :

import sqlite3

conn = sqlite3.connect("/tmp/test.db")
conn.execute("SELECT name, value FROM local_param")

for row in conn:
print row

And I get :

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sqlite3.OperationalError: no such table: local_param


Which I think should be a ProgrammingError

If I fix the table name I but use a wrong column name I also get an
OperationalError

OK OK alright already ... I agree with you ... report a bug.

Cheers,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top