Update statement SQLAlchemy

Eg : 1

page = self.page_q.filter_by(title=title).first()
page.content=escape(request.POST.getone('content'))
Session.commit()

Eg: 2

from sqlalchemy import update

u = update(page_table, page_table.c.title==u'New Title')
connection.execute(u, title=u"Updated Title")

 

equal to =>
UPDATE page SET title=? WHERE page.title = ?
[u’Updated Title’, u’New Title’]

Author: bm on September 12, 2014
Category: SQLAlchemy