On Fri, Sep 2, 2011 at 12:43 PM, Tim Arnold <tim.arn...@sas.com> wrote: > Hi, > I'm using the 'with' context manager for a sqlite3 connection: > > with sqlite3.connect(my.database,timeout=10) as conn: > conn.execute('update config_build set datetime=?,result=? > where id=?', > (datetime.datetime.now(), success, > self.b['id'])) > > my question is what happens if the update fails? Shouldn't it throw an > exception?
That depends on why it fails. If you pass in an id that doesn't exist in the database, it "successfully" updates 0 rows. I would guess that's what happened here. You should check cursor.rowcount after running the update query to make sure it actually did something. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list