Opened 19 years ago

Closed 19 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: dev
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

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 (1)

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

Download all attachments as: .zip

Change History (4)

by anton@…, 19 years ago

Attachment: mysql_base_encoding.diff added

comment:1 by Andy Dustman <farcepest@…>, 19 years ago

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 by me@…, 19 years ago

Cc: me@… added

This is a less elaborate and thorough implementation of #952

comment:3 by Adrian Holovaty, 19 years ago

Resolution: duplicate
Status: newclosed

Closed in favor of #952.

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