Skip to content Skip to sidebar Skip to footer

Mysqldb Can't Initialize Character Set Utf-8 Error

I am trying to insert some Arabic word into the arabic_word column of my hanswehr2 database Maria DB using the MySQLdb driver. I was getting a latin-1 encode error. But after readi

Solution 1:

The charset alias for UTF-8 in MySQL is utf8 (no hyphen).

See https://dev.mysql.com/doc/refman/5.5/en/charset-charsets.html for available charsets.

Note, if you need to use non-BMP Unicode points, such as emojis, use utf8mb4 for the connection charset and the varchar type.

Solution 2:

There is a thing called collations that helps encode/decode characters for specific languages. https://softwareengineering.stackexchange.com/questions/95048/what-is-the-difference-between-collation-and-character-set

I think u need to specify it when creating your databasetableor in the connection string. refer this: store arabic in SQL database

More on python mysql connection : https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlconnection-set-charset-collation.html

Post a Comment for "Mysqldb Can't Initialize Character Set Utf-8 Error"