if you set 'encoding=latin2' on the engine, that is the python-side encoding....its going to convert to raw bytes using value.encode() on the dbapi() side, so not sure why you need to execute stuff per connection. but....
connect() occurs within the connection pool. you can override that behavior by providing your own pool to the engine (darnit, its *almost* documented but not enough), heres the approximate syntax: def myconnect(): con = mysql.connect(db='test', user='test', host='192.168.1.70') con.charset = 'latin2' con.cursor().execute("SET NAMES 'latin2'") return con e = sqlalchemy.mysql.MySQLEngine(pool=sqlalchemy.pool.QueuePool(creator=myconnect)) Qvx 3000 wrote: > After I create MySQL connection I have to patch it in order to work with > my > character encoding. Here is what I'm currently doing: > > from sqlalchemy.ext.proxy import AutoConnectEngine > > __engine__ = AutoConnectEngine('mysql', dict(db='test', user='test', > host=' > 192.168.1.70'), encoding='latin2') > > con = __engine__.engine.connection().connection > con.charset = 'latin2' > con.cursor().execute("SET NAMES 'latin2'") > > > I guess this only works for the current thread. > > I would like to invoke last two statements every time a mysql connection > is > made. > ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users