pymysql won't handle some diacritic characters - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: pymysql won't handle some diacritic characters (/thread-25931.html) |
pymysql won't handle some diacritic characters - awarren2001AD - Apr-16-2020 I'm using the pymysql library in an AWS Lambda function in order to insert records into a MySQL database table. One of the table's columns is intended to hold Welsh language text, which works well for most characters, including diacritics. However, the circumflexed characters w and y are not correctly preserved when written to the database via pymysql - instead they are represented by a question mark when subsequently viewed via a SELECT statement. My pymysql connection object is set as follows: conn = pymysql.connect(host=host_name, user=user_name, password=password, db=db_name, charset='utf8') For instance, when passing the following string via pymysql, every character, apart from the circumflexed w and circumflexed y is correctly written to the database, showing that the database can store UTF-8 characters fine: "Some Welsh diacritics: â, ê, î, ô, û, ŵ, ŷ à, è, ì, À, È. End of diacritics." Note that when INSERTing the string directly using MySQLWorkbench, the circumflexed characters w and y are correctly written to the database, so the problem would seem to lie with pymysql. I don't understand why, for instance, pymysql handles circumflexed u fine but not circumflexed w. Any ideas on how to resolve this issue would be appreciated. |