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

Discussion in 'Python' started by Gabriel Rossetti, Jun 16, 2009.

  1. 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
     
    Gabriel Rossetti, Jun 16, 2009
    #1
    1. Advertising

  2. Gabriel Rossetti

    John Machin Guest

    Re: sqlite3, OperationalError: no such column, shouldn't that ne aProgrammingError?

    On Jun 17, 1:41 am, 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 :
    >

    [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?
     
    John Machin, Jun 16, 2009
    #2
    1. Advertising

  3. Gabriel Rossetti

    Jon Clements Guest

    Re: sqlite3, OperationalError: no such column, shouldn't that ne aProgrammingError?

    On Jun 16, 4:41 pm, 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.
    >
    > 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
     
    Jon Clements, Jun 16, 2009
    #3
  4. Re: sqlite3, OperationalError: no such column, shouldn't that nea ProgrammingError?

    John Machin wrote:
    > On Jun 17, 1:41 am, 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 :
    >>
    >>

    > [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
     
    Gabriel Rossetti, Jun 17, 2009
    #4
  5. Gabriel Rossetti

    John Machin Guest

    Re: sqlite3, OperationalError: no such column, shouldn't that nea ProgrammingError?

    On 17/06/2009 5:15 PM, Gabriel Rossetti wrote:
    > John Machin wrote:
    >> On Jun 17, 1:41 am, 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 :
    >>>
    >>>

    >> [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
     
    John Machin, Jun 17, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. F. GEIGER
    Replies:
    3
    Views:
    1,663
    F. GEIGER
    May 18, 2005
  2. Filipe Sousa
    Replies:
    2
    Views:
    734
    Filipe Sousa
    Sep 6, 2007
  3. Gerhard Häring
    Replies:
    2
    Views:
    1,066
    Gerhard Häring
    Jun 20, 2009
  4. Jeffrey 'jf' Lim
    Replies:
    5
    Views:
    514
    Jeffrey 'jf' Lim
    Apr 9, 2007
  5. nepaul
    Replies:
    2
    Views:
    279
    Peter Otten
    Aug 17, 2012
Loading...

Share This Page