Opened 14 years ago

Closed 14 years ago

#1528 closed enhancement (duplicate)

[patch] MySQL 4.1 charset support

Reported by: anton@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: master
Severity: normal Keywords: mysql 4.1 encoding unicode
Cc: me@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Django forces to use unicode (utf8) when MySQL 4.1 and higher is used as a db backend which is not correct in some cases. For example one creates an application using national encoding (ie windows-1251) for templating etc but Django forces him to use unicode for all db objects.

This patch adds a new parameter to file named DATABASE_CHARSET which is "utf8" by default for backwards compatibility. This parameter will be applied to initial query "SET NAMES %s" when MySQL 4.1 or higher is used as DB backend.

Best regards
Anton Khalikov

Attachments (1)

mysql_base_encoding.diff (1.6 KB) - added by anton@… 14 years ago.

Download all attachments as: .zip

Change History (4)

Changed 14 years ago by anton@…

Attachment: mysql_base_encoding.diff added

comment:1 Changed 14 years ago by Andy Dustman <farcepest@…>

Note that MySQLdb-1.2.1 will have a charset parameter to .connect() which will allow for setting the character set. Just using SQL to set the character set does not get the entire job done, as MySQLdb doesn't realize you've done this and still tries to decode results using the initial character set. I ought to release 1.2.1 by the end of the month (maybe I'll hold out until April 1).

comment:2 Changed 14 years ago by me@…

Cc: me@… added

This is a less elaborate and thorough implementation of #952

comment:3 Changed 14 years ago by Adrian Holovaty

Resolution: duplicate
Status: newclosed

Closed in favor of #952.

Note: See TracTickets for help on using tickets.
Back to Top