Where/Filter From Table Object Using A Dictionary (or **kwargs)
I'm trying to update all Users in the users Table given some criteria. update = ({'username' : 'user1'}, {'address' : '1234', 'password' : 'newpass'}) users = Table(...) I'm tryin
Solution 1:
you can create where clauses list and pass it to where()
from sqlalchemy import and_
update = ({"username" : "user1"}, {"address" : "1234", "password" : "newpass"})
where_clauses = [users.c[key]==value for (key, value) in update[0].items()]
users.update().where(and_(*where_clauses)).values(**update[1])
Post a Comment for "Where/Filter From Table Object Using A Dictionary (or **kwargs)"