except KeyError: print("this was not a key error?")

Discussion in 'Python' started by gert, Oct 11, 2009.

  1. gert

    gert Guest

    gert, Oct 11, 2009
    #1
    1. Advertising

  2. On Oct 10, 7:59 pm, gert <> wrote:
    > http://code.google.com/p/appwsgi/source/browse/appwsgi/wsgi/order.wsgi
    >
    > I screwed up some sql statement
    >
    > INSERT INTO orders (pid,uid,bid,time) VALUES (?,?,2,DATETIME('NOW'))",
    > (v['pid']),s.UID)
    >
    > bid does not exist anymore, but why does the KeyError exception occur
    > when only my sql statement is wrong ?


    Sure it's not from this line?

    def stats2(db,v,s): db.execute("SELECT * FROM orders WHERE bid=? AND
    uid=?",(v['bid'],s.UID))

    It references v['bid']
     
    Michel Alexandre Salim, Oct 11, 2009
    #2
    1. Advertising

  3. gert

    gert Guest

    On Oct 11, 7:48 am, Michel Alexandre Salim
    <> wrote:
    > On Oct 10, 7:59 pm, gert <> wrote:
    >
    > >http://code.google.com/p/appwsgi/source/browse/appwsgi/wsgi/order.wsgi

    >
    > > I screwed up some sql statement

    >
    > > INSERT INTO orders (pid,uid,bid,time) VALUES (?,?,2,DATETIME('NOW'))",
    > > (v['pid']),s.UID)

    >
    > > bid does not exist anymore, but why does the KeyError exception occur
    > > when only my sql statement is wrong ?

    >
    > Sure it's not from this line?
    >
    > def stats2(db,v,s): db.execute("SELECT * FROM orders WHERE bid=? AND
    > uid=?",(v['bid'],s.UID))
    >
    > It references v['bid']


    Hmm that is also a key error :)
     
    gert, Oct 11, 2009
    #3
    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. John Salerno
    Replies:
    20
    Views:
    870
    John Salerno
    Aug 11, 2006
  2. Fabio Z Tessitore

    who is simpler? try/except/else or try/except

    Fabio Z Tessitore, Aug 12, 2007, in forum: Python
    Replies:
    5
    Views:
    389
  3. David House

    try -> except -> else -> except?

    David House, Jul 6, 2009, in forum: Python
    Replies:
    2
    Views:
    357
    Bruno Desthuilliers
    Jul 6, 2009
  4. Peng Yu
    Replies:
    1
    Views:
    547
    Steven D'Aprano
    Nov 18, 2009
  5. Manuel Pégourié-Gonnard

    try/except KeyError vs "if name in ..."

    Manuel Pégourié-Gonnard, Oct 6, 2012, in forum: Python
    Replies:
    7
    Views:
    227
    Ramchandra Apte
    Oct 7, 2012
Loading...

Share This Page