I use python on a server to communicate with mySQL. If a string with non-ascii characters is given to python to convey into a mySQL table field I get this error from the server.
UnicodeEncodeError: 'ascii' codec can't encode characters in position 251-256: ordinal not in range(128)
How can I pass through utf-8 data. I do have the comment:
"# -*- coding: utf-8 -*-"
...included in the python main code page, as well as all the code pages.
Strangely enough I am able to fetch data from mySQL which contains UTF-8 characters and it transfers well down to JavaScript.
The line of code which attempts to transfer the data is as follows:
sql = '''INSERT INTO clientMail (clientID,coID,MessageDate,TypeSent,Comments,FName)
VALUES(%s, %s, '%s', '%s', '%s', '%s') ''' % (clientID,companyID,currentDate,TypeSent,emailMessage,company_Name)
print "===>>>>>>>>>>>>>",sql
The UTF-8 characters occur in the Comments field
Any help would be appreciated...