0

I was trying to insert multiple language support.

So I set name field collation as utf-8 general cli.

When I directly run the below sql query in workbenck. It was inserting the same language.

    INSERT INTO `samba`.`userprofile`(`email`,
    `name`,
    `pass`,`passcode`)
    VALUES
    ('ands@gme1d22.com','ญาณทัสนะ','ana','awer');

When I trying to insert over python script I was inserting like "à¸à¸²à¸“ทัสนะ"

here my python script.

# -*- coding: utf-8 -*-

from gettext import gettext as _

import MySQLdb

try:
        db = MySQLdb.connect("localhost","root","password","samba" )
        cursor = db.cursor()
except:
        print "Database Not Connected"
        sys.exit(1)




query  = """  
        INSERT INTO `samba`.`userprofile`(`email`,
        `name`,
        `pass`,`passcode`)
        VALUES
        ('ands@gme1d22.com','ญาณทัสนะ','ana','awer');
         """

cursor.execute(query)
db.commit()
  • Have you tried this: http://stackoverflow.com/a/8365782/289011 ? Maybe it'll help? – BorrajaX Oct 25 '16 at 17:15
  • 1
    Thanks Its working fine now. – Anandha Kumar Oct 25 '16 at 17:29
  • Also for a reference look at http://dev.mysql.com/doc/refman/5.7/en/charset-column.html and check out your table level and column level charset with the query `show create table \`samba\`.\`userprofile\`` – Drew Oct 25 '16 at 17:33

0 Answers0