title: How do I get an object and update multiple fields in sqlalchemy
body: <p>I want to get an object using primary key, update the object and return it. The examples I saw showing me to update each fields. Something like this:</p>
  
  <pre><code>blog_post = session.query(BlogPost).get(blog_post_id)
  blog_post.name = 'something'
  blog_post.author = 'something'
  session.commit()
  </code></pre>
  
  <p>Problem is I have multiple fields. I don't like updating each field like above. I know I could do something like this: </p>
  
  <pre><code>session.query(BlogPost).filter(blog_post_id).update(data)
  session.commit() 
  </code></pre>
  
  <p>But I want the object I updated and I don't want to query again. Ideally, I would like something like this (following doesn't work, sqlalchemy object has no <code>update</code> method):</p>
  
  <pre><code>blog_post = session.query(BlogPost).get(blog_post_id)
  blog_post.update(data)
  session.commit()
  </code></pre>
  
  <p>What I can do is, I can query and update. And later, fetch the object again. Or I can use a <code>for</code> loop and update each of the fields. But something tells me that it should be already present in sqlalchemy.</p>