0

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
asked Apr 27, 2019 at 10:14
3
  • This question uses a different driver (MySQLdb) but the highest-scoring answer shows a way to configure MySQL to handle unicode. The accepted answer to this question, again for MySQLdb, shows the parameters to set on the connect call. It's worth googling how to best configure MySQL to handle unicode. Take a backup before changing any database settings. Commented Apr 28, 2019 at 11:54
  • Possible duplicate of python cyrillic decode Commented Apr 28, 2019 at 18:46
  • There are probably better duplicates but they depend on how exactly you configured things on the MySQL end. A general possible duplicate is stackoverflow.com/questions/46061496/… Commented Apr 28, 2019 at 19:33

1 Answer 1

0

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.