Solution of "UnicodeEncodeError:'latin-1' codec can't encode character ..." while working with MySQLdb and Python.

Posted on Wed 28 March 2012 in General • Tagged with mysql, mysqldb, pythonLeave a comment

I got the error of "UnicodeEncodeError:'latin-1' codec can't encode character ..." while i was inserting data into mysql with MySQLdb/Python.

Below is the solution:

import MySQLdb as litefire
conx = litefire.connect('127.0.0.1', 'root', '' , 'litefire2' );
conx.set_character_set('utf8')
conr=conx.cursor()
conr.execute('SET NAMES utf8 ...

Continue reading