Sqlalchemy - Updating row with a filter produces List Index Error Sqlalchemy - Updating row with a filter produces List Index Error sqlite sqlite

Sqlalchemy - Updating row with a filter produces List Index Error


I do not think that your code is doing what you want it to do. There are two ways to make an update you want:

1) Directly on the database:

upd = (session.query(Clocktime)       .filter(Clocktime.p_uuid == p_uuid)       .update({"time_out": datetime.datetime.now()})       )print("# of updated rows = {}".format(upd))# session.commit()

2) Load object(s), update the value, and commit the session

upd = (session.query(Clocktime)       .filter(Clocktime.p_uuid == p_uuid)       )# assuming there should be exactly one object for given p_uuid    clockTime = upd.one()clockTime.time_out = datetime.datetime.now()session.commit()