I am not able to connect cassandra from python getting the below error
Traceback (most recent call last):
File "/app/script_max_device_count.py", line 232, in <module>
max_device_count.get_max_device_count_per_partner(partners_dict)
File "/app/script_max_device_count.py", line 199, in get_max_device_count_per_partner
session = self.establish_cassandra_connection()
File "/app/script_max_device_count.py", line 137, in establish_cassandra_connection
session = Cluster([cassandra_host], port=cassandra_port, auth_provider=auth_provider).connect()
File "/usr/local/lib/python3.7/site-packages/cassandra/cluster.py", line 1358, in connect
self.control_connection.connect()
File "/usr/local/lib/python3.7/site-packages/cassandra/cluster.py", line 2896, in connect
self._set_new_connection(self._reconnect_internal())
File "/usr/local/lib/python3.7/site-packages/cassandra/cluster.py", line 2939, in _reconnect_internal
raise NoHostAvailable("Unable to connect to any servers", errors)
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'1XX.XX.X.X:9042': ValueError("invalid literal for int() with base 10: '3-E000'")})
Version used
python = 3.7.4
cassandra-driver==3.18.0
Linux environment
cassandra installed is
[cqlsh 5.0.1 | Cassandra 3.11.3-E000 | CQL spec 3.4.4 | Native protocol v4]
Sample cassandra code connection
``
def establish_cassandra_connection(self):
db_config = DatabaseConfig()
cassandra_host = db_config.get_cassandra_host()
cassandra_port = int(db_config.get_cassandra_port())
cassandra_username = db_config.get_cassandra_username()
cassandra_password = db_config.get_cassandra_password()
auth_provider = PlainTextAuthProvider(username=cassandra_username, password=cassandra_password)
# connection.setup can have multiple host can be added as a list.
session = Cluster([cassandra_host], port=cassandra_port, auth_provider=auth_provider).connect()
logger.info("Cassandra Connection Established.")
return session
``
I am able to resolve this issue this is due to the cassandra driver issue cassandra-driver==3.18.0 was not working with linix version of " Cassandra 3.11.3-E000 "
changed version of assandra-driver==3.14.0 in docker image worked fine