I'm learning and just setup my cassandra cluster and trying to use python as the client to interact with it. In the yaml, I set the authenticator to be PasswordAuthenticator.
So now I plan to provide my username and password over to the connect function but find no where to put them.
cluster = Cluster(hosts)
session = cluster.connect(keyspace)
Basically, you provide only the host and the keyspace. The documentation kind of suggest a connection with anonymous? http://datastax.github.io/python-driver/getting_started.html#connecting-to-cassandra
If I just use the example, I will get the following error
raise NoHostAvailable("Unable to connect to any servers", errors)
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'hou722067': AuthenticationFailed('Remote end requires authentication.',)})
Is the authentication information supplied through some config files? It seems like a very basic functionality and I can't imagine it's not covered in the python client driver. I must have miss something.
In short, my question is: How do I login to cassandra using python?
Thanks in advance for any hint possible!
================================================= Got it figured.
I should provide the username and password in the auth_provider field which is a function returning a dictionary containing ‘username’ and ‘password’ keys with appropriate string values.
Something like
def getCredential(self, host):
credential = {'username':'myUser', 'password':'myPassword'}
return credential
cluster = Cluster(nodes, auth_provider=getCredential)