How to update sqlalchemy orm object by a python dict

You can use setattr() to update attributes on an existing SQLAlchemy object dynamically:

user = session.query(User).get(someid)

for key, value in yourdict.items():
    setattr(user, key, value)

Leave a Comment