-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python 3 Error - expected str instance, bytes found - mysql.insert #20
Comments
Does replacing: solve it? I had a similar problem with the str/bytes difference - under StackStorm-Exchange/stackstorm-openstack#30 (so you could also if I get any review comments on the way I've resolved it in that pack). |
I tried it, and it provided the same error. Looks like it has an issue specifically with
|
I haven't got a mysql server but I took a simplified version of that action, and it looks like the self._escape_string is what is returning bytes. return six.ensure_str(MySQLdb.escape_string(unicode(item).encode('utf-8'))) # pylint: disable=no-member that might resolve the problem. I'm definitely finding that the unicode(item).encode('utf-8') is converting the item to a set of bytes on python 3. |
Looks like that is the trick. Had to do it in another place as well, but I now can test further and will open a PR with the fixes. Thank you so much for your help @amanda11 insert.pyBefore
After
base.pyBefore
After
|
Fixing compatibility for Str/Byte data (Py 2.7 -> 3.x). #20
While testing workflows in preparation for an Ubuntu/Python upgrade, I came across the following error when trying to insert a new row, using a JSON formatted payload. This workflow and formatting works fine in python 2.7.
I investigated and tried troubleshooting a bit, but I could not find a simple solution to submit a PR.
The most useful resource I found was this thread but I was still unable to fix the problem.
I am hoping that someone else can provide some insight and I can further troubleshoot and submit a PR for a fix.
The text was updated successfully, but these errors were encountered: