﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1356	[patch] database charset and mysql backend	little	Adrian Holovaty	"This is moved over from #1355:

2. In django.core.db.backends.mysql.DatabaseWrapper in method cursor()
When you doing
{{{
            self.connection = Database.connect(**kwargs)
        cursor = self.connection.cursor()
        if self.connection.get_server_info() >= '4.1':
            cursor.execute(""SET NAMES 'utf8'"")
}}}
After 'set names ..' the charset of connection was changed. 
But self.connection.charset property (property of MySQLdb.connection) was not changed. It is always 'Latin1'
So, when i pass u""unicode national characters"" into database, MySQLdb tryed to convert it into Latin1 and exception raises

To fix it, i must set .charset propery manually:
{{{
...
            self.connection = Database.connect(**kwargs)
            self.connection.charset = 'utf8'
        cursor = self.connection.cursor()
        if self.connection.get_server_info() >= '4.1':
            cursor.execute(""SET NAMES 'utf8'"")
...
}}}

"	defect	closed	Database layer (models, ORM)		normal	duplicate	mysql charset utf8		Design decision needed	1	0	1	1	0	0
