On Wed, Apr 26, 2006 at 04:32:53PM -0400, Sells, Fred wrote:
> now I've got a dictionary of updates that I want to use to update the db,
> but only if the old data meets certain criteria. So I would like to do
> something like:
>
> row = mytable.get(1)
> for (name,value) in mychanges.items():
> if row.col(name) != '&":
> row.col(name) = value
This will lead to a dozen UPDATEs - one UPDATE for a cycle. Better do
row = mytable.get(1)
update = {}
for (name, value) in mychanges.items():
if getattr(row, name) != '&": # gatattr() is anaviodable here
update[name] = value
if update:
row.set(**update) # UPDATE all values in one query
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss