title: Unresolved "UnicodeEncodeError: 'latin-1' codec can't encode characters in position 86-87: ordinal not in range(256)"
body: <p>I have a bunch of english sentences that I am extracting from a text file to a MYSQL table. This is how I created my table in MYSQL:</p>
  
  <pre><code>create table sentences ( ID int NOT NULL AUTO_INCREMENT ,  sentence varchar (255) , primary key (ID) ) character set = utf8;
  </code></pre>
  
  <p>and this is my python script </p>
  
  <pre><code>from bs4 import BeautifulSoup as b
  import sys
  from fixsentence import *
  import MySQLdb as db
  
  bound = sys.argv[1]
  
  con = db.connect('localhost' , 'root' , 'ayrefik1' , 'knowledgebase2')
  curs = con.cursor()
  
  def gettext(file):
          temp_file = open(file)
          soup = b(temp_file)
          list = get_sentences(soup.get_text())
  
          for x in list:
                  curs.execute('SET NAMES utf8;')
                  curs.execute('insert ignore into sentences (sentence)  values (%s);', (x))
                  con.commit()
  
  
  gettext(bound)
  </code></pre>
  
  <p>And I run the script on a file in this way </p>
  
  <pre><code>python wikitext.py test
  </code></pre>
  
  <p>So even though I specified that the table should be able to handle all characters in UTF-8,
  I still received this error:</p>
  
  <pre><code>UnicodeEncodeError: 'latin-1' codec can't encode characters in position 86-87: ordinal not in range(256)
  </code></pre>