title: Updating a row using SQLAlchemy ORM
body: <p><strong>Note: I am not using Flask-SQLAlchemy here, I'm using SQLAlchemy ORM</strong></p>
  
  <p>I've seen several answers on StackOverflow saying that this is a way to update a record:</p>
  
  <pre><code>session.query(FoobarModel).get(foobar_id).update({'name': 'New Foobar Name!'})
  </code></pre>
  
  <p>However I get an error saying:</p>
  
  <pre><code>AttributeError: 'FoobarModel' object has no attribute 'update'
  </code></pre>
  
  <p>I was able to update like this, however:</p>
  
  <pre><code>foobar = session.query(FoobarModel).get(foobar_id)
  foobar.name = 'New Foobar Name!'
  session.commit()
  session.flush()
  </code></pre>
  
  <p>So then I tried something like this (so that I don't have to write out every property):</p>
  
  <pre><code>new_foobar = {'name': 'New Foobar Name!'}
  old_foobar = session.query(FoobarModel).get(foobar_id)
  
  for property in new_foobar:
    old_foobar[property] = new_foobar[property]
  
  session.commit()
  session.flush()
  </code></pre>
  
  <p>However I then get this error:</p>
  
  <pre><code>TypeError: 'FoobarModel' object does not support item assignment
  </code></pre>
  
  <p>After doing some digging I found out that it's because even this wouldn't work:</p>
  
  <pre><code>print(old_foobar['name'])
  </code></pre>
  
  <p>Which throws the error:</p>
  
  <pre><code>TypeError: 'FoobarModel' object is not subscriptable
  </code></pre>
  
  <p>Honestly the first syntax would be the best in my opinion, but I can't get it to work. Any ideas?</p>