Hi folks,
I have recently started to learn ORM tools in python. I am trying to
write an update query based on a where clause. This is the original
SQL:
UPDATE mail SET fl=20 WHERE f =1 and uid =2 ;
This is what I did in SA:
flTot = 19
fNo = 2
uidNo = 5
a = column('f') + bindparam('fNo')
b = column('uid') + bindparam('uidNo')
ac = a.params({'fNo':fNo})
bc = b.params({'uidNo':uidNo})
ae = ClauseElement.params(ac)
be = ClauseElement.params(bc)
print and_(ae,be)
cache_fl = mail.update(and_(ae,be), values={mail.c.fl:135})
print mysql_db.execute(cache_fl)
The problem is it sets the value of flag for every row in the table
and not just for the where clause condition. Also, I wanted to pick up
the value from variables, so I used bindparams. Is it correct?
Regards,
abhi
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---