|
@@ -19,19 +19,19 @@ import logging
|
|
|
import sys
|
|
import sys
|
|
|
|
|
|
|
|
try:
|
|
try:
|
|
|
- import MySQLdb as Database
|
|
|
|
|
|
|
+ import MySQLdb as Database
|
|
|
except ImportError as e:
|
|
except ImportError as e:
|
|
|
- from django.core.exceptions import ImproperlyConfigured
|
|
|
|
|
- raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
|
|
|
|
|
|
|
+ from django.core.exceptions import ImproperlyConfigured
|
|
|
|
|
+ raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
|
|
|
|
|
|
|
|
# We want version (1, 2, 1, 'final', 2) or later. We can't just use
|
|
# We want version (1, 2, 1, 'final', 2) or later. We can't just use
|
|
|
# lexicographic ordering in this check because then (1, 2, 1, 'gamma')
|
|
# lexicographic ordering in this check because then (1, 2, 1, 'gamma')
|
|
|
# inadvertently passes the version test.
|
|
# inadvertently passes the version test.
|
|
|
version = Database.version_info
|
|
version = Database.version_info
|
|
|
-if (version < (1,2,1) or (version[:3] == (1, 2, 1) and
|
|
|
|
|
|
|
+if (version < (1, 2, 1) or (version[:3] == (1, 2, 1) and
|
|
|
(len(version) < 5 or version[3] != 'final' or version[4] < 2))):
|
|
(len(version) < 5 or version[3] != 'final' or version[4] < 2))):
|
|
|
- from django.core.exceptions import ImproperlyConfigured
|
|
|
|
|
- raise ImproperlyConfigured("MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__)
|
|
|
|
|
|
|
+ from django.core.exceptions import ImproperlyConfigured
|
|
|
|
|
+ raise ImproperlyConfigured("MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__)
|
|
|
|
|
|
|
|
from MySQLdb.converters import FIELD_TYPE
|
|
from MySQLdb.converters import FIELD_TYPE
|
|
|
|
|
|
|
@@ -116,7 +116,8 @@ class MySQLClient(BaseRDMSClient):
|
|
|
'user': self.query_server['username'],
|
|
'user': self.query_server['username'],
|
|
|
'passwd': self.query_server['password'] or '', # MySQL can accept an empty password
|
|
'passwd': self.query_server['password'] or '', # MySQL can accept an empty password
|
|
|
'host': self.query_server['server_host'],
|
|
'host': self.query_server['server_host'],
|
|
|
- 'port': self.query_server['server_port']
|
|
|
|
|
|
|
+ 'port': self.query_server['server_port'],
|
|
|
|
|
+ 'local_infile': False
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if self.query_server['options']:
|
|
if self.query_server['options']:
|
|
@@ -167,7 +168,8 @@ class MySQLClient(BaseRDMSClient):
|
|
|
cursor = self.connection.cursor()
|
|
cursor = self.connection.cursor()
|
|
|
query = 'SHOW TABLES'
|
|
query = 'SHOW TABLES'
|
|
|
if table_names:
|
|
if table_names:
|
|
|
- clause = ' OR '.join(["`Tables_in_%(database)s` LIKE '%%%(table)s%%'" % {'database': database, 'table': table} for table in table_names])
|
|
|
|
|
|
|
+ clause = ' OR '.join(["`Tables_in_%(database)s` LIKE '%%%(table)s%%'" % {'database': database, 'table': table}
|
|
|
|
|
+ for table in table_names])
|
|
|
query += ' FROM `%(database)s` WHERE (%(clause)s)' % {'database': database, 'clause': clause}
|
|
query += ' FROM `%(database)s` WHERE (%(clause)s)' % {'database': database, 'clause': clause}
|
|
|
cursor.execute(query)
|
|
cursor.execute(query)
|
|
|
self.connection.commit()
|
|
self.connection.commit()
|