title: How to encode (utf8mb4) in Python
body: <p>How do I encode something in ut8mb4 in Python? </p>
  
  <p>I have two sets of data: data I am migrating to my new MySQL database over from Parse, and data going forward (that talks only to my new database). My database is utf8mb4 in order to store emoji and accented letters. </p>
  
  <p>The first set of data only shows up correctly (when emoji and accents are involved) when I have in my python script:</p>
  
  <pre><code>MySQLdb.escape_string(unicode(xstr(data.get('message'))).encode('utf-8')) 
  </code></pre>
  
  <p>and when reading from the MySQL database in PHP:</p>
  
  <pre><code>$row["message"] = utf8_encode($row["message"]);
  </code></pre>
  
  <p>The second set of data only shows up correctly (when emoji and accents are involved) when I DON'T include the <code>utf8_encode($row["message"])</code> portion. I am trying to reconcile these so that both sets of data are returned correctly to my iOS app. Please help!</p>