PLANNED MAINTENANCE

Hello, DataStax Community!

We want to make you aware of a few operational updates which will be carried out on the site. We are working hard to streamline the login process to integrate with other DataStax resources. As such, you will soon be prompted to update your password. Please note that your username will remain the same.

As we work to improve your user experience, please be aware that login to the DataStax Community will be unavailable for a few hours on:

  • Wednesday, July 15 16:00 PDT | 19:00 EDT | 20:00 BRT
  • Thursday, July 16 00:00 BST | 01:00 CEST | 04:30 IST | 07:00 CST | 09:00 AEST

For more info, check out the FAQ page. Thank you for being a valued member of our community.


question

toni.rbaena_181533 avatar image
toni.rbaena_181533 asked ·

Avoid warnings Cassandra python

Hi all, i want to connect from a Cassandra Database using python driver.


I can connect using cassandra-driver, but i have several warning when i run the code in pycharm:


from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider


server_config = {
"host": "172.XX.XX.XX",
"port": "9042",
"user": "XXXXXXXXX",
"password": "XXXXXXXX",
"keySpace": "XXXXXX"
}


keyspace = server_config['keySpace']

auth_provider = PlainTextAuthProvider(username=server_config['user'],
                                      password=server_config['password'])

node_ips = [server_config['host']]



cluster = Cluster(contact_points=node_ips, 
                  load_balancing_policy=None,
                  port=int(server_config['port']), 
                  auth_provider=auth_provider, 
                  protocol_version=3)

session = cluster.connect()

session.set_keyspace(keyspace)




WARNING:cassandra.cluster:Cluster.__init__ called with contact_points specified, but no load_balancing_policy. In the next major version, this will raise an error; please specify a load-balancing policy. (contact_points = ['172.18.64.19'], lbp = None)

WARNING:cassandra.connection:An authentication challenge was not sent, this is suspicious because the driver expects authentication (configured authenticator = PlainTextAuthenticator)
INFO:cassandra.policies:Using datacenter 'datacenter1' for DCAwareRoundRobinPolicy (via host '172.18.64.19'); if incorrect, please specify a local_dc to the constructor, or limit contact points to local cluster nodes

WARNING:cassandra.connection:An authentication challenge was not sent, this is suspicious because the driver expects authentication (configured authenticator = PlainTextAuthenticator)


How can i connect more efficiently ?


Thanks !

cassandrapython-driver
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

toni.rbaena_181533 avatar image
toni.rbaena_181533 answered ·

Thanks for your anwser, but i still have a warning message.

When i add


ALTER KEYSPACE XXXXX   WITH REPLICATION = {     'class' : 'NetworkTopologyStrategy',     'datacenter1' : 1    } ;


and use the code you wrote, I have this message :


DeprecationWarning: Legacy execution parameters will be removed in 4.0. Consider using execution profiles.  "execution profiles.", DeprecationWarning)
Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

aboudreault avatar image
aboudreault answered ·

Hi,


To avoid those warnings, you should follow their recommendations. Here are additional details about them:


1. The first one recommend to specify a load balancing policy. In your code snippet, you configured it to None, which is the same than not configure it at all. Prefer configuring it explicitly based on your cluster configuration. Example:

# This example assume that *datacenter1* if a valid DC for your cluster.
Cluster(contact_points=node_ips, 
        load_balancing_policy=DCAwareRoundRobinPolicy(local_dc='datacenter1'),
        port=int(server_config['port']), 
        auth_provider=auth_provider, 
        protocol_version=3)

2. The second one is just saying that you should remove the auth_provider configuration because the cluster/node you are connecting to doesn't have authentication enabled.

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.