Hi Mart,
to be able to use the key in the update you have to pass it in a dict.
I would do:
id=db.local_user.insert(dateTime=datetime.now())
# you seem to be updating one rec only
rec = db(db.local_user.id==id)
for key,value in localUserDict.items():
if key in db.local_user.fields:
rec.update(**{key:value})
db.commit() # after all updates are in
or using a comprehension:
id=db.local_user.insert(dateTime=datetime.now())
# you seem to be updating one rec only
rec = db(db.local_user.id==id)
[rec.update(**{key:value}) for key,value in localUserDict.items() if
key in db.local_user.fields]
db.commit() # after all updates are in
Denes.
On Jul 10, 11:55 pm, mart <[email protected]> wrote:
> Hi,
>
> shouldn't something lik this work? or maybe i'm missing something for
> passing in a variable for a field name?
>
> id=db.local_user.insert(dateTime=datetime.now())
> for key in localUserDict.keys():
> for field in db.local_user.fields:
> if field==key:
>
> db(db.local_user.id==id).update(field=localUserDict[key])
> db.commit()
>
> the exception is of course that the Field field does not belong to the
> local_user table
>
> Thanks,
> Mart :)