Thanks Rick and everyone for your response !
I will post here how i resolved my issue :
After digging much deeper on the issues where actually it wasn't necessary because the answer was in front of me all the time lol.
Since I'm using Apache Airflow, and the connection configuration I missed to add was in extra {"charset":"utf8"}
. And did solved it ! here is the reference (https://airflow.apache.org/docs/apache-airflow-providers-mysql/stable/connections/mysql.html)
Additionally my mysql.cnf configuration is set-not sure if it'll make any difference though- as:
[client]
default-character-set = utf8mb4
[mysqld]
skip-character-set-client-handshake
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
init-connect = SET NAMES utf8mb4
[mysql]
default-character-set = utf8mb4
Also for table:
CREATE TABLE IF NOT EXISTS `test_sample` (
`ID` int(10) NOT NULL,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
And I removed all the -not needed anymore- in MySqlHook connection code:
source_cursor.execute("SET NAMES utf8;")
source_cursor.execute("SET CHARACTER SET utf8;")
source_cursor.execute("SET character_set_connection=utf8;")
Hope it helps others the same, Cheers!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…