Django

Code

Ticket #1528 (closed: duplicate)

Opened 3 years ago

Last modified 3 years ago

[patch] MySQL 4.1 charset support

Reported by: anton@khalikov.ru Assigned to: adrian
Milestone: Component: Database layer (models, ORM)
Version: SVN Keywords: mysql 4.1 encoding unicode
Cc: me@julik.nl Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

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 settings.py 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

mysql_base_encoding.diff (1.6 kB) - added by anton@khalikov.ru on 03/21/06 23:52:30.

Change History

03/21/06 23:52:30 changed by anton@khalikov.ru

  • attachment mysql_base_encoding.diff added.

03/22/06 19:19:53 changed by Andy Dustman <farcepest@gmail.com>

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).

03/24/06 16:47:17 changed by me@julik.nl

  • cc set to me@julik.nl.

This is a less elaborate and thorough implementation of #952

04/23/06 16:43:44 changed by adrian

  • status changed from new to closed.
  • resolution set to duplicate.

Closed in favor of #952.


Add/Change #1528 ([patch] MySQL 4.1 charset support)




Change Properties
Action