【发布时间】:2015-03-26 22:20:54
【问题描述】:
我在通过 python 驱动程序查询我的 cassandra 数据库时遇到问题。
我的 cassandra 版本是 python2.7
>>> import cassandra
>>> cassandra.__version__
'2.1.3'
>>>
我的代码:
def search_data(self, ticker):
row = self.session.execute("""select * from secmaster.ticker_name where ticker = %s""",(ticker))
print row
得到错误:
File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 1293, in execute
future = self.execute_async(query, parameters, trace)
File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 1342, in execute_async
future = self._create_response_future(query, parameters, trace)
File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 1373, in _create_response_future
query_string = bind_params(query_string, parameters, self.encoder)
File "/usr/local/lib/python2.7/dist-packages/cassandra/query.py", line 727, in bind_params
return query % tuple(encoder.cql_encode_all_types(v) for v in params)
TypeError: not all arguments converted during string formatting
但如果我做下面的查询它确实有效
def search_data(self, ticker):
row = self.session.execute("""select * from secmaster.ticker_name""")
print row
【问题讨论】:
标签: python python-2.7 cassandra