Python Forum
pymysql won't handle some diacritic characters
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pymysql won't handle some diacritic characters
#1
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Mysql Syntax error in pymysql ilknurg 4 2,364 May-18-2022, 06:50 AM
Last Post: ibreeden
  pymysql can't do SELECT * Pedroski55 3 2,975 Sep-11-2021, 10:18 PM
Last Post: Pedroski55
  Remove escape characters / Unicode characters from string DreamingInsanity 5 13,735 May-15-2020, 01:37 PM
Last Post: snippsat
  pyMySQL - ROW_NUMBER in SQL statement JayCee 1 2,384 Apr-12-2020, 08:40 PM
Last Post: JayCee
  pyMySQL How do I get the row id JayCee 3 2,715 Apr-12-2020, 08:38 PM
Last Post: JayCee
  PyMySQL return a single dictionary Valon1981 2 1,791 Feb-20-2020, 04:07 PM
Last Post: Valon1981
  pymysql: formating ouput of query wardancer84 18 8,360 Oct-04-2018, 01:54 PM
Last Post: wardancer84
  pymysql ifnull aland 4 3,994 Sep-06-2018, 05:58 AM
Last Post: buran
  get last row id in pymysql tony1812 1 11,171 Sep-26-2017, 11:25 PM
Last Post: Larz60+
  pymysql question tony1812 1 2,897 Sep-26-2017, 12:41 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020