2

In a certain context it would be useful to disable character escaping of a query string or at least disable specifically '%' character escaping.

Is such thing possible? How?

I know it is possible to escape that character with '%%' but I want to avoid doing that.

Simple query example:

SELECT '%2C'

Expected result:

'%2C'

I'm using sqlalchemy and pymysql.

Zupo Llask
  • 21
  • 4
  • when I run that in DBeaver using postgresql it returns one row with the string value `%2C`. What is your expected output? If you're looking to use a regex you might be able to use `REGEXP_MATCHES(source_string, pattern [, flags])`. Overall it's going to be hard to answer your question without some more context. – Hugh_Kelley Aug 27 '19 at 11:05
  • Have a look at https://stackoverflow.com/questions/10935854/how-to-escape-in-a-query-using-pythons-sqlalchemys-execute-and-pymysql – Ilja Everilä Aug 27 '19 at 11:30
  • @Hugh_Kelley I've just updated my question with the expected result. I know the example seems dumb, because I'm presenting a very simplified example precisely targeting my intent. – Zupo Llask Aug 27 '19 at 11:49
  • @IljaEverilä Maybe this will work in my use case... I'll test it! Initially was narrowing the question too much around pymysql... I'll give feedback later. – Zupo Llask Aug 27 '19 at 11:52
  • 1
    @IljaEverilä That's it! It totally solves my use case and feels like the right way to do it. I guess this must be marked as a duplicate of that other question. Thanks! – Zupo Llask Aug 27 '19 at 12:15

0 Answers0