无法从命令行或python

时间:2017-03-29 16:09:48

标签: python cassandra datastax cql cqlsh

我试图在python的文件上运行SOURCE cqlsh shell命令,我很难决定解决方案。最初我尝试使用Cassandra Datastax驱动程序从游标执行,但这导致以下错误:

File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 2012, in execute
    return self.execute_async(query, parameters, trace, custom_payload, timeout, execution_profile, paging_state).result()
  File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 3801, in result
    raise self._final_exception
cassandra.protocol.SyntaxException: <Error from server: code=2000 [Syntax error in CQL query] message="line 1:0 no viable alternative at input 'SOURCE' ([SOURCE]...)">

然后我尝试使用-e标志从命令行运行shell命令,并收到以下错误:

sudo cqlsh -e "SOURCE '~/dev/cql_files/file.cql'" -k xxx 12.345.678.910 9160
Usage: cqlsh [options] [host [port]]

cqlsh: error: no such option: -e

如果我使用-f标志运行,则执行文件:

sudo cqlsh -f cql_files/file.cql -k xxx 12.345.678.910 9160

我应该使用子进程库来调用上面的语句,还是应该打开文件并逐行执行每个语句?哪个是更好的解决方案?谢谢!

0 个答案:

没有答案