I have written a python script which get data from database and process it.
Initially I was using pymysql for connecting database which I changed to MySQL Connector for python. When I started using MySQL Connector I am getting following issue
'ascii' codec can't encode characters in position 14-16: ordinal not in range(128)
I tried by adding charset settings of MySQL Connector but issue still persists.
Do anyone have idea on this issue?
ascii
encodingExample:
CREATE TABLE t1(
col1 char,
....,
....,
....
)Engine=InnoDB charset=ascii;
assci
encoding and enable unicode db = MySQLdb.connect(
host="localhost",
port=3306,
user="john",
passwd="megajonhy",
db="jonhydb",
use_unicode=True,
charset='ascii'
)
I believe that by default use_unicode
is set to False
, and thus by setting it True
you will fix the issue.