SQLAlchemy, MySQL and UTF-8

While SQLAlchemy uses UTF-8 by default, the charset used when communicating with MySQL will affect the encoding of the returned data. To be sure that everything is handled properly as UTF-8 (which you might use SET NAMES 'utf8' in the console (don’t do that here..)), add ?charset=utf8 to your connection url:

  1. mysql://user:password@localhost/database?charset=utf8

Thanks to RustyFluff at StackOverflow.

Tags: , ,

Leave a Reply