Hello.

I'm using Python 2.6, SQLAlchemy 0.7.1, MySQL 5.5 and MySQLdb 1.2.3.

I'm creating engine with following connect string: mysql+mysqldb://localhost/test_1?charset=utf8&sql_mode=STRICT_ALL_TABLES' and convert_unicode parameter set to True.

Now when I call connection.execute(sql) I'm receiving utf-8 encoded strings for each entry from VARCHAR column. The same thing happens when I call query(myModel).all(). From what I can see in SA docs I should've receive unicode objects instead.

When I change my connect string by adding use_unicode=0, apparently SA starts to convert rows returned by MySQLdb and query(myModel).all() returns unicode objects, not strings. But still connection.execute(sql) returns strings encoded with utf-8.

I suppose that MySQLdb fails to convert strings to unicode, and when I explicitly mark that I don't want such conversion with use_unicode=0, SA adds processor to each VARCHAR column but it works only when I use ORM constructs. When I try executing raw SQL queries SA doesn't do any type conversion.

Now is this expected behaviour, or is SA supposed to convert all string output to unicode when convert_unicode is set to True, even when it is result of plain SQL execution?

Does anyone know how to fix it - should I set some additional flag in MySQLdb or in SA when I create engine or connection?

Regards,
    Adam Bielański.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to