Ticket #952: encoding.2.diff
File encoding.2.diff, 3.1 KB (added by , 19 years ago) |
---|
-
django/conf/project_template/settings.py
15 15 DATABASE_PASSWORD = '' # Not used with sqlite3. 16 16 DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. 17 17 DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. 18 DATABASE_ENCODING = '' # Set to encoding name used by your database 19 # (i.e. 'utf8' for MySQL or 'unicode' for Postgres). Not used with sqlite3. 18 20 19 21 # Local time zone for this installation. All choices can be found here: 20 22 # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE -
django/core/db/backends/postgresql.py
15 15 self.queries = [] 16 16 17 17 def cursor(self): 18 from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, D EBUG, TIME_ZONE18 from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DATABASE_ENCODING, DEBUG, TIME_ZONE 19 19 if self.connection is None: 20 20 if DATABASE_NAME == '': 21 21 from django.core.exceptions import ImproperlyConfigured … … 31 31 conn_string += " port=%s" % DATABASE_PORT 32 32 self.connection = Database.connect(conn_string) 33 33 self.connection.set_isolation_level(1) # make transactions transparent to all cursors 34 35 if DATABASE_ENCODING: 36 self.connection.cursor().execute("SET CLIENT_ENCODING TO "+DATABASE_ENCODING) 37 34 38 cursor = self.connection.cursor() 35 39 cursor.execute("SET TIME ZONE %s", [TIME_ZONE]) 36 40 if DEBUG: -
django/core/db/backends/mysql.py
53 53 self.queries = [] 54 54 55 55 def cursor(self): 56 from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, D EBUG56 from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DATABASE_ENCODING, DEBUG 57 57 if self.connection is None: 58 58 kwargs = { 59 59 'user': DATABASE_USER, … … 65 65 if DATABASE_PORT: 66 66 kwargs['port'] = DATABASE_PORT 67 67 self.connection = Database.connect(**kwargs) 68 69 if DATABASE_ENCODING: 70 self.connection.cursor().execute("SET NAMES "+DATABASE_ENCODING) 71 68 72 if DEBUG: 69 73 return base.CursorDebugWrapper(MysqlDebugWrapper(self.connection.cursor()), self) 70 74 return self.connection.cursor()