Giter VIP home page Giter VIP logo

Comments (4)

namachieli avatar namachieli commented on September 25, 2024 1

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.py

Before
query = "INSERT INTO {} ({}) VALUES ({})".format(table.encode('utf-8'), columns, values)
After
query = "INSERT INTO {} ({}) VALUES ({})".format(six.ensure_str(table.encode('utf-8')), columns, values)

base.py

Before
    def _escape_string(self, item):
        return MySQLdb.escape_string(unicode(item).encode('utf-8'))
After
    def _escape_string(self, item):
        return six.ensure_str(MySQLdb.escape_string(unicode(item).encode('utf-8')))

from stackstorm-mysql.

amanda11 avatar amanda11 commented on September 25, 2024

Does replacing:
self._escape_string(item)
with
self._escape_string(six.ensure_string(item))

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).

from stackstorm-mysql.

namachieli avatar namachieli commented on September 25, 2024

I tried it, and it provided the same error. Looks like it has an issue specifically with for item in data]). When trying something like str(item) i see the following error:

  File \"/opt/stackstorm/packs/mysql/actions/lib/base.py\", line 50
    for str(item) in data])
       ^
SyntaxError: can't assign to function call

from stackstorm-mysql.

amanda11 avatar amanda11 commented on September 25, 2024

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.
So I think if you leave the list_to_string alone, but instead change escape_string to be something like:

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.

from stackstorm-mysql.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.