title: How can I verify Column data types in the SQLAlchemy ORM?
body: <p>Using the SQLAlchemy ORM, I want to make sure values are the right type for their columns.</p>
  
  <p>For example, say I have an Integer column. I try to insert the value “hello”, which is not a valid integer. SQLAlchemy will allow me to do this. Only later, when I execute <code>session.commit()</code>, does it raise an exception: <code>sqlalchemy.exc.DataError: (DataError) invalid input syntax integer: "hello"…</code>.</p>
  
  <p>I am adding batches of records, and I don’t want to commit after every single <code>add(…)</code>, for performance reasons.</p>
  
  <p>So how can I:</p>
  
  <ul>
  <li>Raise the exception as soon as I do <code>session.add(…)</code></li>
  <li>Or, make sure the value I am inserting can be converted to the target Column datatype, <em>before</em> adding it to the batch?</li>
  <li>Or any other way to prevent one bad record from spoiling an entire <code>commit()</code>.</li>
  </ul>