LookupError: unknown encoding: utf8mb3
I have super simple example of BinLogStreamReader:
mysql_settings = {'host': host, 'port': port, 'user': user, 'passwd': passw }
stream = BinLogStreamReader( connection_settings=mysql_settings, server_id=1024, is_mariadb=True, # blocking=True, only_events=[DeleteRowsEvent, UpdateRowsEvent, WriteRowsEvent], # resume_stream=True, only_tables=[table], only_schemas=[schema] )
which goes on exception on line "for row in binlogevent.rows:"
for binlogevent in stream: for row in binlogevent.rows: print(row) stream.close()
Traceback (most recent call last):
File "C:\Users\user\Desktop\pyProjects\replica\binlogreader\test.py", line 93, in
I added these lines in pymsql/charset.py and LookupError was fixed. _charsets.add(Charset(256, "utf8mb3", "utf8mb3_general_ci", "Yes")) _charsets.add(Charset(257, "utf8mb3", "utf8mb3_bin", ""))
but I am not sure if this is a good practice...
Hello, I have the exact same issue.
I am also looking for a more long-term fix rather than juste tweaking the pymysql library.
@blackoctop did you try to submit a PR to pymysql to include your fix?
@the4thdoctor I opened issue and got this answer:
methane commented 24 days ago This is pymysqlreplication issue.
@methane methane closed this as [not planned]
:facepalm:
We also got this issue when I updated MySQL RDS from version 5.7 to 8.0.
In MySQL 8.0, the utf8mb3 character set is deprecated, so tables/columns with the utf8mb3 character set gave the error. So we have changed the character set of our tables from utf8mb3 to utf8mb4.
ALTER TABLE sh.subjects
DEFAULT CHARACTER SET utf8mb4,
MODIFY subject_desc varchar(50)
CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL;
Ref. https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-deprecations
I added these lines in pymsql/charset.py and LookupError was fixed. _charsets.add(Charset(256, "utf8mb3", "utf8mb3_general_ci", "Yes")) _charsets.add(Charset(257, "utf8mb3", "utf8mb3_bin", ""))
but I am not sure if this is a good practice...
this worked for me! was wondering if anybody found a better solution though?
I added these lines in pymsql/charset.py and LookupError was fixed. _charsets.add(Charset(256, "utf8mb3", "utf8mb3_general_ci", "Yes")) _charsets.add(Charset(257, "utf8mb3", "utf8mb3_bin", ""))
but I am not sure if this is a good practice...
thanks!