title: Insert value into VARBINARY column using sqlalchemy
body: <p>I am using a MS SQL database, together with Python and sqlalchemy. One table has a column defined as    </p>
  
  <pre><code>CREATE TABLE MyTable (
      ...
      [address] [varbinary] (16) NULL
      ...
  </code></pre>
  
  <p>The table class <code>MyTable</code> is generated by means of table reflection. 
  Assigning a string value to <code>MyTable.address</code> in my Python code triggers the exception</p>
  
  <pre><code>sqlalchemy.exc.StatementError: (builtins.TypeError) string argument without an encoding
  </code></pre>
  
  <p>when writing it to the database. Passing a <code>bytearray</code> instead yields the database error</p>
  
  <pre><code>(pymssql.OperationalError) (257, 
  b'Implicit conversion from data type varchar to varbinary is not allowed. 
  Use the CONVERT function to run this query.DB-Lib error message 20018, severity 16 [...]
  </code></pre>
  
  <p>I understand that an encoding is required to store a string in a binary column, but how can I provide that encoding? How else could I write binary data to the database using the ORM capabilities of sqlalchemy?</p>
  
  <p>For I am creating my table classes through reflection, I cannot modify the SQL code directly like described in the answer to <a href="https://stackoverflow.com/q/25804024/220000">Insert binary file into MSSQL db (varbinary) with python pymssql</a></p>
  
  <p>Reading the <a href="http://docs.sqlalchemy.org/en/latest/dialects/mssql.html" rel="nofollow noreferrer">sqlalchemy documentation on MS SQL</a> also yielded no solution.</p>