diff --git a/MySQLdb/cursors.py b/MySQLdb/cursors.py index bc1334b7..4d807a96 100644 --- a/MySQLdb/cursors.py +++ b/MySQLdb/cursors.py @@ -22,6 +22,23 @@ text_type = str +def convert_to_str(var): + """ + Convert various datatypes to str + Required for Python 3 + """ + if isinstance(var,tuple): + return tuple(convert_to_str(item) for item in var) + if isinstance(var,list): + return ([convert_to_str(item) for item in var]) + elif isinstance(var,dict): + return {convert_to_str(key):convert_to_str(value) for key,value in var.items()} + elif isinstance(var,bytes): + return var.decode('utf-8', 'ignore') + + return var + + #: Regular expression for :meth:`Cursor.executemany`. #: executemany only supports simple bulk insert. #: You can use it to load large dataset. @@ -444,6 +461,9 @@ def fetchall(self): else: result = self._rows self.rownumber = len(self._rows) + if not PY2: + db = self._get_db() + result = tuple(convert_to_str(result)) return result def scroll(self, value, mode='relative'): diff --git a/README.md b/README.md index cd91383d..317a55ee 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,14 @@ [![Build Status](https://secure.travis-ci.org/PyMySQL/mysqlclient-python.png)](http://travis-ci.org/PyMySQL/mysqlclient-python) +### This is a fork of a fork + +This fork corrects a byte string error between PyMySQL/mysqlclient-python, Python3, and Saltstack. This error prevented the Saltstack mysql_grants module from working correctly. + + + +### From the original + This is a fork of [MySQLdb1](https://github.com/farcepest/MySQLdb1). This project adds Python 3 support and bug fixes.