title: Python - 'unknown encoding: utf8mb4' when using ON DUPLICATE KEY UPDATE
body: <p>Like the title says I am receiving the error 'unknown encoding: utf8mb4' when I try to use ON DUPLICATE KEY UPDATE. I dont get this error if I use an INSERT IGNORE instead but then I lose the ability to upsert. This is what my code looks like:</p>
  
  <pre><code>MySQL version: 5.7.14-google-log
  Python: 3.6.5
  mysql-connector: 2.1.6
  
  
  def mysqlLoader(vals, table, headers):
  dbCon = mysql.connector.connect(
      host="-",
      user="-",
      passwd="-",
      database="-",
      charset='utf8mb4'
  )
  
  cursor = dbCon.cursor()
  sql = generateSQL(table, headers, vals)
  try:
      dbCon.autocommit = False
      cursor.execute('SET NAMES utf8mb4')
      cursor.execute("SET CHARACTER SET utf8mb4")
      cursor.execute("SET character_set_connection=utf8mb4")
      print('Executing SQL query...')
      cursor.executemany(sql, vals)
      print('Commiting to MySQL...')
      dbCon.commit()
      print("MySQL Updated Successfully! %s records inserted!" % cursor.rowcount)
  except Exception as e:
      print("Could not commit entries: %s" % e)
      sendEmail('Data Loader Failed', 'Table: %s\r\nError: %s' % (table, e))
  
  
  def generateSQL(table, headers, vals):
      valStrings = getSQLStrings(vals)
      updateVals = getUpdateString(headers)
      sql = 'INSERT INTO %s (%s) VALUES (%s) ON DUPLICATE KEY UPDATE %s' % (table, headers, valStrings, updateVals)
      print("Query created.")
      return sql
  
  def getUpdateString(headers):
  """Outputs an ON DUPLICATE UPDATE string using the given headers."""
  temp = ''
  split = headers.split(', ')
  for item in split:
      temp += '%s=VALUES(%s), ' % (item, item)
  temp = temp[:(len(temp)-2)]
  return temp
  </code></pre>
  
  <p>I can strip out emojis and other characters and revert back to utf8 but I would prefer to keep them for data integrity. Any help would be much appreciated.</p>
  
  <p>EDIT: It seems to be an issue with the executemany command. When I run inserts one at a time I dont throw an error.</p>