Re: [SQLObject] a simple question and small code changes
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Peter W. <pw-...@te...> - 2003-04-03 16:29:54
|
On Thursday, April 3, 2003, at 05:11 AM, Ian Bicking wrote: > You can call .destroy() on the instance you want to kill. It should > probably be a class method, as self-destruction isn't very pythonic... > but anyway, it's there. > Thanks very much Ian - I should have seen that in source... I did notice that with SQLite due to the way it locks the db you can't do something like: for p in Person.select(...): p.destroy() # this will throw an error about the db being locked I imagine this looping and deleting would work fine on other db's so maybe some note in the docs could help anyone else that hits this. Another question... How do you normally deal with knowing if a row exists in the database? e.g. (looking for person id 12 which doesn't exist in db) p = Person(12) p.id will return 12 p.name throws an error (likewise for other columns) Would something along the lines of p.exists() make any sense? Oh and I'm new-ish to Python so I may well being missing the obvious :-) -- peter w. |