SQLCell icon indicating copy to clipboard operation
SQLCell copied to clipboard

Percent sign throwing "dict object does not support indexing error" error

Open tmthyjames opened this issue 9 years ago • 3 comments

SELECT * FROM table WHERE column LIKE '%''%' LIMIT 10

does not work. Searching for column that contains an apostrophe.

tmthyjames avatar Sep 26 '16 18:09 tmthyjames

Maybe a problem with sqlalchemy as

engine.execute("SELECT * FROM table WHERE column LIKE '%''%' LIMIT 10")

doesn't work either.

tmthyjames avatar Sep 26 '16 23:09 tmthyjames

SQLAlchemy docs: http://docs.sqlalchemy.org/en/rel_0_9/core/ddl.html?highlight=ddl#sqlalchemy.schema.DDL.params.statement

Single percent signs are to be escaped using double percent signs.

Therefore, the above code should

SELECT * FROM table WHERE column LIKE '%%''%%' LIMIT 10

tmthyjames avatar Sep 26 '16 23:09 tmthyjames

Thinking of adding

cell = cell.replace('%', '%%')

right before the cell param is executed as SQL, but not quite sure yet of the repercussions.

tmthyjames avatar Sep 26 '16 23:09 tmthyjames