I am trying to use sqlalchemy to connect with mysql database. I have set up charset=utf-8$use_unicode=0
. This worked with almost all databases, but not with a particular one. I believe it is because it has 'init-connect' variable set to 'SET NAMES latin2;'
I have no privileges to change that.
It works for me if I send explicit query SET NAMES utf8
, however if there is a temporal disconnection, then after reconnecting my program breaks again as it gets lati2-encoded data from the server.
Is it possible to create some hook to always send the SET NAMES
when sqlalchemy connects? Or any other way to solve this problem?