如何在Hadoop上运行的Cloudera Impala的python impyla查询中转义字符

时间:2017-05-13 14:08:53

标签: python hadoop cloudera impala impyla

我试图在Hadoop上的Cloudera Impala的python impyla查询中转义字符,但似乎没有任何工作..模板语法不会转义(对于数据库API不常见..)

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

产生错误。

甚至

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

不起作用,有没有人知道如何为此提供解决方案?是否有更好的方法或更全功能的Python Impala库?

1 个答案:

答案 0 :(得分:0)

您可以对r占位符

使用参数化查询

?

然而,impyla仍然存在引用转义和unicode的其他问题,我还没有完全弄明白。