Skip to content

Instantly share code, notes, and snippets.

@hieuhani
Created October 12, 2018 10:58
Show Gist options
  • Save hieuhani/e955e82df28654a71a0cefca8a0a55cf to your computer and use it in GitHub Desktop.
Save hieuhani/e955e82df28654a71a0cefca8a0a55cf to your computer and use it in GitHub Desktop.
result = db.session.execute(
db
.update(Contact, values={'value': payload['value']}, returning=Contact.__table__.columns)
.where(Contact.id == payload['id'])
)
db.session.commit()
fetched_data = result.first()
contact = {}
for (index, column) in enumerate(result.keys()):
contact[column] = fetched_data[index]
return Contact(**contact)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment