While printing Cyrillic text from MySQL in my python3 program I get question marks instead of text.
The text I see in the MySQL table is Рожден ден.
The text I see in the python3 program is ?????? ???.
Type of row is class str.
For this list, I am using wxpython, wx module.
conn = pymysql.connect(host='localhost', database='Tasks', password='password', user='user')
cursor = conn.cursor()
cursor.execute('SELECT occasion,date,event FROM Important_Days')
records = cursor.fetchall()
for row in records:
pos = self.list1.InsertStringItem(0, row[0])
self.list1.SetStringItem(pos, 1, str(row[1]))
self.list1.SetStringItem(pos, 2, row[2])
conn.close()
snakecharmerb
57.2k13 gold badges137 silver badges201 bronze badges
1 Answer 1
The question marks were created during the INSERTs, there is no way to get the Cyrillic out of them.
See "question mark" in Trouble with UTF-8 characters; what I see is not what I stored
See this for notes on Python: http://mysql.rjweb.org/doc.php/charcoll#python
answered May 1, 2019 at 3:56
Rick James
144k15 gold badges144 silver badges255 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default
connectcall. It's worth googling how to best configure MySQL to handle unicode. Take a backup before changing any database settings.