From 342d93588cadbf72a741ed44d3a8950463bc01e2 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Thu, 17 Mar 2022 11:04:27 -0500 Subject: [PATCH 1/4] Fix parameter changes in MySQLdb v2.1 --- memsql/common/database.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/memsql/common/database.py b/memsql/common/database.py index 3510a17..d4e4fcf 100644 --- a/memsql/common/database.py +++ b/memsql/common/database.py @@ -1,6 +1,7 @@ """A lightweight wrapper around _mysql.""" from MySQLdb import _mysql +import MySQLdb import time import operator @@ -55,6 +56,13 @@ def __init__(self, host, port=3306, database="information_schema", user=None, pa assert isinstance(options, dict), "Options to database.Connection must be an dictionary of { str: value } pairs." args.update(options) + # Fix for parameter name changes in mysqlclient v2.1.0 + if MySQLdb.version_info[:2] >= (2, 1): + if "db" in args: + args["database"] = args.pop("db") + if "passwd" in args: + args["password"] = args.pop("passwd") + self._db = None self._db_args = args From 6085b43a49d6c9b710f4f743d15eda43071d2c1c Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Thu, 17 Mar 2022 11:42:35 -0500 Subject: [PATCH 2/4] Check for binary flag for conversions --- memsql/common/conversions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/memsql/common/conversions.py b/memsql/common/conversions.py index cbc0390..9582878 100644 --- a/memsql/common/conversions.py +++ b/memsql/common/conversions.py @@ -1,4 +1,4 @@ -from MySQLdb.constants import FIELD_TYPE +from MySQLdb.constants import FIELD_TYPE, FLAG from MySQLdb.converters import conversions, Bool2Str from MySQLdb import times, _mysql import datetime @@ -9,10 +9,10 @@ def _bytes_to_utf8(b): return b.decode('utf-8') -CONVERSIONS[FIELD_TYPE.STRING] = _bytes_to_utf8 -CONVERSIONS[FIELD_TYPE.VAR_STRING] = _bytes_to_utf8 -CONVERSIONS[FIELD_TYPE.VARCHAR] = _bytes_to_utf8 -CONVERSIONS[FIELD_TYPE.BLOB] = _bytes_to_utf8 +CONVERSIONS[FIELD_TYPE.STRING] = ((FLAG.BINARY, bytes), (None, _bytes_to_utf8)) +CONVERSIONS[FIELD_TYPE.VAR_STRING] = ((FLAG.BINARY, bytes), (None, _bytes_to_utf8)) +CONVERSIONS[FIELD_TYPE.VARCHAR] = ((FLAG.BINARY, bytes), (None, _bytes_to_utf8)) +CONVERSIONS[FIELD_TYPE.BLOB] = ((FLAG.BINARY, bytes), (None, _bytes_to_utf8)) def _escape_bytes(b, c): return _mysql.string_literal(b, c).decode('utf-8') From 6f6f555d0c5b2becb499549b98a5ef450de1dac0 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Thu, 17 Mar 2022 12:05:56 -0500 Subject: [PATCH 3/4] Move changes to another branch --- memsql/common/conversions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/memsql/common/conversions.py b/memsql/common/conversions.py index 9582878..cbc0390 100644 --- a/memsql/common/conversions.py +++ b/memsql/common/conversions.py @@ -1,4 +1,4 @@ -from MySQLdb.constants import FIELD_TYPE, FLAG +from MySQLdb.constants import FIELD_TYPE from MySQLdb.converters import conversions, Bool2Str from MySQLdb import times, _mysql import datetime @@ -9,10 +9,10 @@ def _bytes_to_utf8(b): return b.decode('utf-8') -CONVERSIONS[FIELD_TYPE.STRING] = ((FLAG.BINARY, bytes), (None, _bytes_to_utf8)) -CONVERSIONS[FIELD_TYPE.VAR_STRING] = ((FLAG.BINARY, bytes), (None, _bytes_to_utf8)) -CONVERSIONS[FIELD_TYPE.VARCHAR] = ((FLAG.BINARY, bytes), (None, _bytes_to_utf8)) -CONVERSIONS[FIELD_TYPE.BLOB] = ((FLAG.BINARY, bytes), (None, _bytes_to_utf8)) +CONVERSIONS[FIELD_TYPE.STRING] = _bytes_to_utf8 +CONVERSIONS[FIELD_TYPE.VAR_STRING] = _bytes_to_utf8 +CONVERSIONS[FIELD_TYPE.VARCHAR] = _bytes_to_utf8 +CONVERSIONS[FIELD_TYPE.BLOB] = _bytes_to_utf8 def _escape_bytes(b, c): return _mysql.string_literal(b, c).decode('utf-8') From 84b8660251ced54b6a4a8a5127953d05c1ba4901 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Thu, 17 Mar 2022 13:36:21 -0500 Subject: [PATCH 4/4] Update MySQLdb version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fcbf909..1615248 100755 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ 'wraptor', 'simplejson', 'python-dateutil<3.0', - 'mysqlclient<2.0', + 'mysqlclient>=1.4', ] class PyTest(TestCommand):