こんなエラー
Traceback (most recent call last):
....
cursor.execute(sql)
File "/home/user/.local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 188, in execute
query = query.encode(db.encoding)
File "/usr/lib/python3.6/encodings/cp1252.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_table)
UnicodeEncodeError: 'charmap' codec can't encode characters in position 486-487: character maps to <undefined>
対策
デフォルトでlatin-1を使うらしいので、接続時に明示的にエンコードコード方法を指定
conn = MySQLdb.connect(
host=host,
db=dbname,
port=port,
user=user,
passwd=password,
use_unicode=True,
★これ charset="utf8mb4"
)