mercredi 22 avril 2015

Sqlalchemy - Updating row with a filter produces List Index Error

I hope this is my last question pertaining to this pet project of mine.

I'm trying to update table Clocktimes (column = time_out) with the current time. I want to select by a UUID that I create with UUID4. When I run the code, I get ListIndex out of range error, on a function in query.py (a part of Sqlalchemy). I've listed that rather short function below my code.

My code:

out = session.query(). \
        filter(Clocktime.p_uuid == p_uuid). \
        update(Clocktime.time_out == datetime.datetime.now())
    session.add(out)
    session.commit()

Sqlalchemy code throwing error:

def _entity_zero(self):
    return self._entities[0]

The Sqlalchemy code is pretty complex so I haven't looked through it yet, but my theory is that it doesn't like my filter for some reason. Anyway, I can't figure it out - do any of you have any idea?

Aucun commentaire:

Enregistrer un commentaire