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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.