I want to calculate the addition with exisiting value.
e.g. MySQL:
UPDATE TBL SET val = +1 WHERE id = 1
How can I do in SQLAlchemy?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do this via the SQLAlchemy Core via just referencing the field name (example taken from here):
In your case, this would probably look something like…
If you need more complex behavior, you can look at correlated updates: essentially, creating a select object that represents the new value you want (based on the old one) and setting that as the value in your update object’s
values.