On Friday, September 2, 2011 11:43:53 AM UTC-7, Tim Arnold 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?
If you look at the sqlite3 syntax documentation, you'll see it has a SQL
extension that allows you to specify error semantics. It looks something like
this:
UPDATE OR IGNORE
UPDATE OR FAIL
UPDATE OR ROLLBACK
I'm not sure exactly how this interacts with pysqlite3, but using one of these
might help it throw exceptions when you want it to.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list