Cassandra python 错误在输入 'SOURCE' 时没有可行的替代方案 ([SOURCE]...)">
Cassandra python error no viable alternative at input 'SOURCE' ([SOURCE]...)">
当我尝试 运行 来自 python 的以下命令时(我正在使用带有 Python 2.7.6 的 Cassandra Datastax Python 驱动程序)
cluster = Cluster([CASSANDRA_HOST], port=CASSANDRA_PORT, cql_version=CASSANDRA_CQL_VERSION, protocol_version=3)
session = cluster.connect(CASSANDRA_KEYSPACE)
NEW_ID = "9999999999"
CQL_FILE_NAME = "FNAME-"+NEW_ID+".cql"
cql_cmd = "SOURCE '~/dev/cql_files/"+ CQL_FILE_NAME + "'"
session.execute(cql_cmd)
我收到以下错误:
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]...)">
但是当我 运行 来自 cqlsh 的相同字符串时 运行 没问题。关于我应该改变什么的任何想法?谢谢!
字符串如下所示:
"SOURCE '~/dev/cql_files/FNAME-9999999999.cql'"
SOURCE
是 cqlsh 独有的命令,它实际上不是 CQL 规范的一部分,因此您不能通过客户端驱动程序使用它:
Important: The CQL shell commands described in this section work only within the cqlsh shell and are not accessible from drivers. CQL shell uses native protocol and the Datastax python driver to execute CQL commands on the connected Cassandra host. For configuration information, see the Cassandra 3.0 cassandra.yaml file.
当我尝试 运行 来自 python 的以下命令时(我正在使用带有 Python 2.7.6 的 Cassandra Datastax Python 驱动程序)
cluster = Cluster([CASSANDRA_HOST], port=CASSANDRA_PORT, cql_version=CASSANDRA_CQL_VERSION, protocol_version=3)
session = cluster.connect(CASSANDRA_KEYSPACE)
NEW_ID = "9999999999"
CQL_FILE_NAME = "FNAME-"+NEW_ID+".cql"
cql_cmd = "SOURCE '~/dev/cql_files/"+ CQL_FILE_NAME + "'"
session.execute(cql_cmd)
我收到以下错误:
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]...)">
但是当我 运行 来自 cqlsh 的相同字符串时 运行 没问题。关于我应该改变什么的任何想法?谢谢!
字符串如下所示:
"SOURCE '~/dev/cql_files/FNAME-9999999999.cql'"
SOURCE
是 cqlsh 独有的命令,它实际上不是 CQL 规范的一部分,因此您不能通过客户端驱动程序使用它:
Important: The CQL shell commands described in this section work only within the cqlsh shell and are not accessible from drivers. CQL shell uses native protocol and the Datastax python driver to execute CQL commands on the connected Cassandra host. For configuration information, see the Cassandra 3.0 cassandra.yaml file.