PyMySQL/mysqlclient

BLOB data can't be decoded

charles-001 opened this issue · 1 comments

Hello. I'm creating a top tool for MySQL and it seems BLOB data it reads from SHOW PROCESSLIST can't be decoded if it has characters from another character set.

The error I get is:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 2043: invalid continuation byte

With pymysql, the error is:
InternalError: Packet sequence number wrong - got 7 expected 1.

With mysql.connector , the error is:
InternalError: Unread result found

My default character set is utf8mb4, and from what I read 0xed is a latin1 character.

Is there anything I can do to fix this? It seems like it's a Python driver issue. I have a similar tool in Perl + PHP and neither have this type of issue. I'm curious why Python seems to fail to work with BLOB data.

traceback.txt

Thank you in advance

It seems like it's a Python driver issue. I have a similar tool in Perl + PHP and neither have this type of issue. I'm curious why Python seems to fail to work with BLOB data.

Because string in Python is Unicode but string in Perl or PHP is not.

Use use_unicode=False.