Sorry I've seen the question answered before but can't seem to solve the problem. I'm trying to properly encode my SQL columns so it will accept emojis:
def create_table():
    op = '''CREATE TABLE conversation (
    text TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL,
    intent TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
    entities TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
    reply TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL
    )'''
    cursor.execute(op)
def insert_message(text, intent, entities, reply):
    try:
        #avoid using placeholders to prevent SQL injection, will pass text, intent and entities to transaction_builder() instead
        sql = """INSERT INTO conversation  (text, intent, entities, reply) VALUES (%s, %s, %s, %s)"""
        transaction_builder(sql, text, intent, entities, reply)
    except Exception as e:
        print ('error is', str(e))
with open('C:/Users/ELITEBOOK/documents/github/chatbot/chatbot/bot/robot_text.txt','r') as table:
        for robo_line in table.readlines():
            message_reply = robo_line
            message_intent = ''
            message_entities = ''
            insert_message(message_text, message_intent, message_entities, message_reply)
There's some code missing but this is what is relevant. It looks to me like the encoding should be set but it seems like it's not. Sorry if this is a duplicate
edit:
Traceback
1366 (HY000): Incorrect string value: '\xF0\x9F\x98\x81\xF0\x9F...' for column 'reply' at row 1
