【问题标题】:cassandra cql query substitutioncassandra cql 查询替换
【发布时间】:2012-01-07 11:58:45
【问题描述】:

举例说明:

import cql
cql connect to CF/Keyspace
last_key = XYZ (say it's getting fetched from else where)
cursor.execute(select * from domain_dimension where key=:key", key="last_key")

CQL 文档说可以做到,但在控制台上说 execute() 得到了意外的关键字参数。

Cassandra CQL 真的支持查询替换吗?

【问题讨论】:

    标签: cassandra cql pycassa


    【解决方案1】:

    看起来您需要将 dict 中的替换作为单个 arg 传递,而不是作为关键字 args。

    cursor.execute("select * from domain_dimension where key=:key", {'key': last_key})
    

    在项目主页的示例中是这样指定的:http://code.google.com/a/apache-extras.org/p/cassandra-dbapi2/

    【讨论】:

    • 因为python语法无效或者你得到一个cql异常说它是无效的cql语法?
    • python 语法无效,错误点位于该行。你能试试吗?提前致谢
    • 啊,是的,这不是有效的python。主页应该更新。我将编辑我的回复。
    • Cassandra CQL 查询替换确实不起作用。有人可以帮忙吗?谢谢!
    • 您在我的回复中尝试了新代码吗?现在是什么错误?它对我有用。
    猜你喜欢
    • 2019-05-18
    • 2015-03-10
    • 2019-05-04
    • 1970-01-01
    • 2013-10-14
    • 2013-01-02
    • 1970-01-01
    • 2014-11-15
    • 2013-06-07
    相关资源
    最近更新 更多