Opened 10 years ago

Closed 10 years ago

#1528 closed enhancement (duplicate)

[patch] MySQL 4.1 charset support

Reported by: anton@… Owned by: adrian
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: UI/UX:


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@… 10 years ago.

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by anton@…

comment:1 Changed 10 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 10 years ago by me@…

  • Cc me@… added

This is a less elaborate and thorough implementation of #952

comment:3 Changed 10 years ago by adrian

  • Resolution set to duplicate
  • Status changed from new to closed

Closed in favor of #952.

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