title: how to save utf-8 characters from python to mySQL
body: <p>I use python on a server to communicate with mySQL.  If a string with non-ascii characters is given to python to convey into a mySQL table field I get this error from the server.</p>
  
  <pre><code>UnicodeEncodeError: 'ascii' codec can't encode characters in position 251-256: ordinal not in range(128)
  </code></pre>
  
  <p>How can I pass through utf-8 data.  I do have the comment:</p>
  
  <pre><code>"# -*- coding: utf-8 -*-"
  </code></pre>
  
  <p>...included in the python main code page, as well as all the code pages.</p>
  
  <p>Strangely enough I am able to fetch data from mySQL which contains UTF-8 characters and it transfers well down to JavaScript.</p>
  
  <p>The line of code which attempts to transfer the data is as follows:</p>
  
  <pre><code>sql = '''INSERT INTO clientMail (clientID,coID,MessageDate,TypeSent,Comments,FName)
          VALUES(%s, %s, '%s', '%s', '%s', '%s') ''' % (clientID,companyID,currentDate,TypeSent,emailMessage,company_Name)
  print "===&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;",sql
  </code></pre>
  
  <p>The UTF-8 characters occur in the Comments field</p>
  
  <p>Any help would be appreciated...</p>