Here is a simple example of using pymysql (Python 3):
import pymysql
conn = pymysql.connect(user='admin', passwd='...', host='host', use_unicode=True)
c = conn.cursor()
c.execute("SELECT category FROM product LIMIT 0,1")
print (type(c.fetchone()[0]))
It returns
<class 'bytes'>
The type of the field is varchar and I thought if I specify use_unicode=True it shoud return field value as str instead of bytes. Yes, I do know that I can convert bytes to str, but I don't want to.
Is it possible to get str right away? What do I do wrong?
The problem was in the field's collation. Since it was set to utf8_bin pymysql counted it as binary in spite of it was varchar. Changing the collation to utf8_general_ci solved the problem.