2012-01-07 159 views
1

说明一个例子:卡桑德拉CQL查询替代

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是否真的支持查询替换?

回答

4

看起来你需要将字典中的替换作为单个参数传递,而不是作为关键字参数传递。

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

也就是说它在该项目主页上的例子,如何规定:http://code.google.com/a/apache-extras.org/p/cassandra-dbapi2/

+0

我试过了尼克,它说无效的语法! – Nish 2012-01-07 01:41:56

+0

由于在python语法无效,或者你得到一个cql异常,说它是无效的cql语法? – nickmbailey 2012-01-07 02:59:21

+0

python语法无效,错误指向该行。你可以试试吗?在此先感谢 – Nish 2012-01-07 03:46:10