Ticket #1528: mysql_base_encoding.diff

File mysql_base_encoding.diff, 1.6 KB (added by anton@…, 19 years ago)
  • django/conf/global_settings.py

     
    8383DATABASE_PASSWORD = ''         # Not used with sqlite3.
    8484DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
    8585DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
     86DATABASE_CHARSET = 'utf8'      # Used with MySQL 4.1.x and higher
    8687
    8788# Host for sending e-mail.
    8889EMAIL_HOST = 'localhost'
  • django/core/db/backends/mysql.py

     
    5353        self.queries = []
    5454
    5555    def cursor(self):
    56         from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DEBUG
     56        from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DATABASE_CHARSET, DEBUG
    5757        if self.connection is None:
    5858            kwargs = {
    5959                'user': DATABASE_USER,
     
    6767            self.connection = Database.connect(**kwargs)
    6868        cursor = self.connection.cursor()
    6969        if self.connection.get_server_info() >= '4.1':
    70             cursor.execute("SET NAMES utf8")
     70            cursor.execute("SET NAMES %s" % DATABASE_CHARSET)
    7171        if DEBUG:
    7272            return base.CursorDebugWrapper(MysqlDebugWrapper(cursor), self)
    7373        return cursor
Back to Top