sqlite3 with context manager
Ian Kelly
ian.g.kelly at gmail.com
Sat Sep 3 00:38:22 EDT 2011
More information about the Python-list mailing list
Sat Sep 3 00:38:22 EDT 2011
- Previous message (by thread): sqlite3 with context manager
- Next message (by thread): sqlite3 with context manager
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Sep 2, 2011 at 12:43 PM, Tim Arnold <Tim.Arnold at 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
- Previous message (by thread): sqlite3 with context manager
- Next message (by thread): sqlite3 with context manager
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list