Fixing MySQLdb encoding issues with Python

Are you running into encoding issues with MySQLdb on Python? Have you searched high and low only to be told to change your my.cnf settings and create tables with the proper encoding, yet it STILL doesn’t work? In that case, be sure to specify charset='utf8' in your MySQLdb.connect(...) along with the rest of the required parameters. This tiny, neglected setting is what’s actually used to encode unicode back for MySQL. Not configuration files, not table settings, just that.

Of course, you should have a table with a utf8 charset for it to work, but this is the setting that will prevent those latin-1 encoding issues when you swore you didn’t say latin-1 anywhere.