title: Python to SQL Server insert query to varbinary(max) column
body: <p>I am performing an insert query from Python (3.6) to SQL Server. I am trying to insert a bytes datatype into a <code>varbinary(max)</code> column.</p>
  <p>Now, the query executes successfully but value in the SQL Server column is not correct. Not sure what I am missing.</p>
  <p>Is the data getting converted to some other format? How can this be rectified? Any pointers in the right direction will be appreciated.</p>
  <p>Edit: In Python it's alphanumeric but when inserted into the sql server it is only numbers.</p>
  <pre><code>cn = pyodbc.connect()
  cr = cn.cursor()
  script=&quot;&quot;&quot; insert into table (Col1, col2) values (?,?)&quot;&quot;&quot; # Col1 is varbinary(max) column
  VBM = VBM.encode('utf-8')#Bytes information corresponding to the varbinary(max) column
  values = (VBM, FN) 
  cur.execute(Script, values)
  cn.commit()
  </code></pre>
  <p>VBM in Python:</p>
  <pre><code>b'0x443611119900554616035D15220'
  </code></pre>
  <p>VBM when inserted into SQL Server:</p>
  <pre><code>0x307834353143313131313936303
  </code></pre>