I'm using SQLobject and so far was not able to find a elegant solution for "update row in the db or vreate a new one if it doesn't exist.
Currently I use following somewhat convoluted code:
args = dict(artnr=artnr, name=name, hersteller='?', hersteller_name='?')
if cs.datamart.ArtNrNameHersteller.selectBy(artnr=artnr).count():
row = cs.datamart.ArtNrNameHersteller.selectBy(artnr=artnr)[0]
row.set(**args)
else:
cs.datamart.ArtNrNameHersteller(**args)
Obviously this is far from bening consise, robust, elegant or fast. What is the correct way(TM) to do this?