Linux, 工作, 生活, 家人

Programming

Python mysql.connector.errors.DataError: 1366 (22007): Incorrect string value:

After check all mysql (mariadb) setting, I realize that should be client issue, it needs to add “chatset=’utf8mb4′” to mysql.connector.connect command.

mydb = mysql.connector.connect(
    host="IP or Host",
    user="<user>",
    passwd="<password>",
    database="<yourDB>",
    # set charset to utf8mb4 to support emojis
    charset='utf8mb4'
)

ref. https://stackoverflow.com/a/73648817/1371373

發佈留言