Reputation:
I am trying to update a record using sqlalchemy.
tableA.query().\
filter(tableA.id== 9080).\
update({"bankbalance": (tableA.bankbalance+1)})
tableA.commit()
In tableA, there are two columns - id and bankbalance. I want to update the bankbalance for the person with id 9080.
But the query is not working because I am getting the error below.
TypeError: 'BaseQuery' object is not callable
Upvotes: 1
Views: 45
Reputation: 3157
Use db.session.query(), if you don't query a model.
db.session.query(tableA).filter(tableA.id == 9080).\
update({"bankbalance": (tableA.bankbalance+1)})
db.session.commit()
Upvotes: 1