Exceptions on delete in pysqlite

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun Jan 27 12:45:24 EST 2008


En Fri, 25 Jan 2008 22:12:57 -0200, Wildemar Wildenburger  
<lasses_weil at klapptsowieso.net> escribi�:

> Using pysqlite, I'd like to check if some dataset that I removed has
> been in the database at all. Ideally I'd like pysqlite to raise an
> Exception if deleting does nothing. Is that possible?

I don't think so. It isn't an error, like a SELECT which returns an empty  
set isn't an error either.

> Codewise, I'd like the following, but without me checking for and
> raising the exception myself:
>
> cur = con.execute("""DELETE FROM SomeTable WHERE id=? AND name=?""",
>                       (ID, NAME))
> if cur.rowcount == 0:
>      raise Exception

Write a function to do that.

-- 
Gabriel Genellina




More information about the Python-list mailing list