Bug #88657 LookupError: unknown encoding: utf8mb4
Submitted: 25 Nov 2017 23:33 Modified: 27 Nov 2017 12:09
Reporter: Imnot Tellingyou Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / Python Severity:S2 (Serious)
Version:2.1.7 OS:Any
Assigned to: CPU Architecture:Any
Tags: charset, prepared statement, utf8mb4

[25 Nov 2017 23:33] Imnot Tellingyou
Description:
When using a connection with charset 'utf8mb4' executing a prepared statement results in this (non-prepared statements seem to work just fine):

Traceback (most recent call last):
  File "demo.py", line 5, in <module>
    c.execute('select id from mytable where filename = %s', ('test123',))
  File "/usr/lib/python3.6/site-packages/mysql/connector/cursor.py", line 1172, in execute
    operation = operation.encode(self._connection.charset)
LookupError: unknown encoding: utf8mb4

Might be related to #82948.

How to repeat:
import mysql.connector

conn = mysql.connector.connect(host='localhost', database='test', user='test', password='test', charset='utf8mb4')
c = conn.cursor(prepared=True)
c.execute('select id from mytable where filename = %s', ('test123',))
[27 Nov 2017 12:09] Chiranjeevi Battula
Hello Imnot Tellingyou,

Thank you for the bug report.
Verified as described with the help of dev's.

Thanks,
Chiranjeevi.