Ticket #2810: mysql-encoding.diff

File mysql-encoding.diff, 1.4 KB (added by dummy@…, 18 years ago)
  • django/conf/global_settings.py

     
    9999DATABASE_PASSWORD = ''         # Not used with sqlite3.
    100100DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
    101101DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
     102DATABASE_ENCODING = 'utf8'     # for MySQL >= 4.1
    102103
    103104# Host for sending e-mail.
    104105EMAIL_HOST = 'localhost'
  • django/db/backends/mysql/base.py

     
    6161    def __init__(self):
    6262        self.connection = None
    6363        self.queries = []
     64        from django.conf import settings
     65        self.encoding = settings.DATABASE_ENCODING   
    6466
    6567    def _valid_connection(self):
    6668        if self.connection is not None:
     
    9092            self.connection = Database.connect(**kwargs)
    9193        cursor = self.connection.cursor()
    9294        if self.connection.get_server_info() >= '4.1':
    93             cursor.execute("SET NAMES 'utf8'")
     95            cursor.execute("SET NAMES '%s'" % self.encoding)
    9496        if settings.DEBUG:
    9597            return util.CursorDebugWrapper(MysqlDebugWrapper(cursor), self)
    9698        return cursor
Back to Top