【问题标题】:How to escape characters in python impyla query for Cloudera Impala running on Hadoop如何在 Hadoop 上运行的 Cloudera Impala 的 python impyla 查询中转义字符
【发布时间】:2017-05-13 14:08:52
【问题描述】:

我试图在 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 库?

【问题讨论】:

  • 您可以编辑它以显示产生的错误吗?

标签: python hadoop cloudera impala impyla


【解决方案1】:

您可以使用带有? 占位符的参数化查询

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

但是 impyla 仍然存在我尚未完全弄清楚的引号转义和 unicode 的其他问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多