Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm Unable to connect using python Cassandra-Driver

What might I be missing? I'm Unable to connect using python Cassandra-Driver however I seem to be able to connect fine when using the CQL module.

cluster = Cluster(
contact_points=['10.x.x.xx',],
port=9160)

session = cluster.connect()
session.set_keyspace("mykeyspace")

Output:

cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'10.0.x.xx': ConnectionShutdown('Connection to 10.0.x.xx is closed',)})

Also, I'm hosting cassandra from a virtual machine with a single node if that matters.

like image 596
EnergyGeek Avatar asked Apr 30 '14 18:04

EnergyGeek


People also ask

Can Cassandra be used with Python?

Python module for working with Cassandra database is called Cassandra Driver. It is also developed by Apache foundation. This module contains an ORM API, as well as a core API similar in nature to DB-API for relational databases. Installation of Cassandra driver is easily done using pip utility.

What version of Python does Cassandra use?

The driver supports Python 2.7, 3.4, 3.5, and 3.6.


1 Answers

The DataStax Python driver (which is what it looks like you are using) is using the native protocol and that uses the 9042 port by default. If you checking your conf file (cassandra.yaml), make sure you have the start_native_transport: true (default value since 1.2)

like image 50
Alex Popescu Avatar answered Nov 01 '22 16:11

Alex Popescu