title: How to fix "can't adapt error" when saving binary data using python psycopg2
body: <p>I ran across this bug three times today in one of our projects.  Putting the problem and solution online for future reference.</p>
  
  <pre><code>impost psycopg2
  
  con = connect(...)
  
  def save(long_blob):
       cur = con.cursor() 
       long_data = struct.unpack('&lt;L', long_blob)
       cur.execute('insert into blob_records( blob_data ) values (%s)', [long_data])
  </code></pre>
  
  <p>This will fail with the error "can't adapt" from psycopg2.</p>