If i try to update a record that does not exist, then it should throw a 1 or something aside from 0.
If you try to update a record that does not exist, .update()
will return None
, so the insert will then happen. If matching records exist, .update()
will return the number of records updated.
In any case, you should instead do:
mydb.myitems.update_or_insert(mydb.myitems.itemNumber == int(row),
oldImageName=filename)
or alternatively:
mydb.myitems.update_or_insert(dict(itemNumber == int(row)),
oldImageName=filename)
The first argument to update_or_insert
is _key
, which can either be a DAL query or a dictionary with field names as keys.