From f21cbb40b2521da1195d1a2aa5910281efb32b7f Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 30 Dec 2006 07:21:01 +0000 Subject: [PATCH] Fixed #3151 -- Improved MySQL backend not to send 'SET NAMES utf8' before every query. Thanks for the patch, smurf@smurf.noris.de git-svn-id: http://code.djangoproject.com/svn/django/trunk@4267 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- AUTHORS | 1 + django/db/backends/mysql/base.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index 645913e7c4..fef8e09b75 100644 --- a/AUTHORS +++ b/AUTHORS @@ -151,6 +151,7 @@ answer newbie questions, and generally made Django that much better: serbaut@gmail.com Pete Shinners SmileyChris + smurf@smurf.noris.de sopel Thomas Steinacher nowell strite diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index e7e060e6c2..28c5b1c683 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -98,9 +98,11 @@ class DatabaseWrapper(local): kwargs['port'] = int(settings.DATABASE_PORT) kwargs.update(self.options) self.connection = Database.connect(**kwargs) - cursor = self.connection.cursor() - if self.connection.get_server_info() >= '4.1': - cursor.execute("SET NAMES 'utf8'") + cursor = self.connection.cursor() + if self.connection.get_server_info() >= '4.1': + cursor.execute("SET NAMES 'utf8'") + else: + cursor = self.connection.cursor() if settings.DEBUG: return util.CursorDebugWrapper(MysqlDebugWrapper(cursor), self) return cursor