Opened 19 years ago
Closed 19 years ago
#1528 closed enhancement (duplicate)
[patch] MySQL 4.1 charset support
Reported by: | 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)
Change History (4)
by , 19 years ago
Attachment: | mysql_base_encoding.diff added |
---|
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).