0

I am trying to escape characters in python impyla query for Cloudera Impala on Hadoop but nothing seems to work.. The template syntax doesn't escape (Unusual for a database API..)

cursor.execute('SELECT * from table where col1 = %s', tuple(["John's unescaped string"]))

produces an error.

Even

cursor.execute('SELECT * from table where col1 = %s', tuple([json.dumps("John's unescaped string")]))

doesn't work, does anyone have any idea how to provide a solution for this? Is there a better way or a more fully featured Impala library for Python?

user1688726
  • 319
  • 2
  • 4
  • 11

1 Answers1

0

You can use a parameterized query with ? placeholders

cursor.execute('INSERT INTO table VALUES (?, ?);', (var1, var2))

However impyla does still have other issues with quote-escaping and unicode that I haven't fully figured out yet.

Alex Hofsteede
  • 251
  • 2
  • 5