I found the issue here. I need to do following two things to get rid of it -
First, setting default character set to Unicode in Python script -
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
Second, while connecting to db, set the parameters use_unicode
and charset
-
conn = pymysql.connect(host='xx', user='xx', passwd='xx', db='xx', use_unicode=True, charset='utf8')