Code

Ticket #2810: mysql-encoding.diff

File mysql-encoding.diff, 1.4 KB (added by dummy@…, 8 years ago)
Line 
1Index: django/conf/global_settings.py
2===================================================================
3--- django/conf/global_settings.py      (Revision 3817)
4+++ django/conf/global_settings.py      (Arbeitskopie)
5@@ -99,6 +99,7 @@
6 DATABASE_PASSWORD = ''         # Not used with sqlite3.
7 DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
8 DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
9+DATABASE_ENCODING = 'utf8'     # for MySQL >= 4.1
10 
11 # Host for sending e-mail.
12 EMAIL_HOST = 'localhost'
13Index: django/db/backends/mysql/base.py
14===================================================================
15--- django/db/backends/mysql/base.py    (Revision 3817)
16+++ django/db/backends/mysql/base.py    (Arbeitskopie)
17@@ -61,6 +61,8 @@
18     def __init__(self):
19         self.connection = None
20         self.queries = []
21+        from django.conf import settings
22+        self.encoding = settings.DATABASE_ENCODING   
23 
24     def _valid_connection(self):
25         if self.connection is not None:
26@@ -90,7 +92,7 @@
27             self.connection = Database.connect(**kwargs)
28         cursor = self.connection.cursor()
29         if self.connection.get_server_info() >= '4.1':
30-            cursor.execute("SET NAMES 'utf8'")
31+            cursor.execute("SET NAMES '%s'" % self.encoding)
32         if settings.DEBUG:
33             return util.CursorDebugWrapper(MysqlDebugWrapper(cursor), self)
34         return cursor