python - Unable to complete the operation against any hosts cassandra -
i have tried previous solutions stated here , here. using cassandra-driver datastax. version of cassandra 2.2.8.i have created keyspace ct_keyspace
, ct_table
within it. inserted values in ct_table through cqlsh
prompt. following python code retrieving rows
from cassandra.cluster import cluster cluster = cluster() session = cluster.connect('ct_keyspace') result = session.execute("select * ct_table") print result.attribute, result.value
following output of describe ct_keyspace:
cqlsh> describe ct_keyspace create keyspace ct_keyspace replication = {'class': 'simplestrategy', 'replication_factor': '1'} , durable_writes = true; create table ct_keyspace.ct_table ( attribute text primary key, value int ) bloom_filter_fp_chance = 0.01 , caching = '{"keys":"all", "rows_per_partition":"none"}' , comment = '' , compaction = {'class': 'org.apache.cassandra.db.compaction.sizetieredcompactionstrategy'} , compression = {'sstable_compression': 'org.apache.cassandra.io.compress.lz4compressor'} , dclocal_read_repair_chance = 0.1 , default_time_to_live = 0 , gc_grace_seconds = 864000 , max_index_interval = 2048 , memtable_flush_period_in_ms = 0 , min_index_interval = 128 , read_repair_chance = 0.0 , speculative_retry = '99.0percentile';
following error getting:
traceback (most recent call last): file "connection.py", line 4, in <module> result = session.execute("select * ct_table") file "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 1998, 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 3781, in result raise self._final_exception cassandra.cluster.nohostavailable: ('unable complete operation against hosts', {})
any appreciated.
this happening because providing wrong keyspace name in connect. use "ct_keyspace" instead of "ct_keyspace". may recall unquoted identifiers case-insensitive in cql (such select statement). however, in context of parameter passing (as in cluster.connect(<keyspace>)
) literal not case-insensitive.
if enable logging, see driver continually failing set keyspace on connection. created ticket improve error handling in scenario: https://datastax-oss.atlassian.net/browse/python-665
Comments
Post a Comment