Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

sylD avatar image
sylD asked ·

Failed to connect to Astra with Python driver, "got an unexpected keyword argument 'cloud'"

Hello,
Following the default how to once the Database created (https://astra.datastax.com/) I'm facing the issue

Traceback (most recent call last):                                                                                                                
  File "photos.py", line 19, in <module>                                                                                                          
    cluster = Cluster(cloud=cloud_config, auth_provider=auth_provider)                                                                            
  File "cassandra/cluster.py", line 843, in cassandra.cluster.Cluster.__init__                                                                    
TypeError: __init__() got an unexpected keyword argument 'cloud'       
The begining of the python script is this one :
  1 from confluent_kafka import Consumer, KafkaError
  2 from cassandra.cluster import Cluster
  3 from cassandra.auth import PlainTextAuthProvider
  4 
  5 import boto3
  6 import exifread
  7 import json
  8 import os
  9 
 10 def dms2dd(degrees, minutes, seconds):
 11      dd = float(degrees) + float(minutes)/60 + float(seconds)/3600
 12      return dd
 13 
 14 
 15 cloud_config= {
 16         'secure_connect_bundle': './secure-connect-database54400.zip'
 17 }
 18 auth_provider = PlainTextAuthProvider('databaseusername', 'databasepassword')
 19 cluster = Cluster(cloud=cloud_config, auth_provider=auth_provider)
 20 session = cluster.connect()

If you get idea I will appreciate,

Thanks & Regards,

astra
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.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

I suspect that the problem is that you haven't provided the full path to your secure bundle.

If your secure bundle is in /home/syid/astra, your configuration should have:

cloud_config= {
        'secure_connect_bundle': '/home/syid/astra/secure-connect-database_name.zip'
}

Try that and let me know how you go. Cheers!

[UPDATE] My other suspicion is that you're using an old version of the Python driver.

Support for Astra was added in version 3.20.0. Please check the version you're running. I suggest you upgrade to the latest.

2 comments 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.

Hello Erick !

Thanks for your answers,
You right, the issue was coming from the driver which was too old,

Have a nice day,

Kind Regards,

2 Likes 2 ·

Glad to hear and thanks for confirming the resolution. Cheers!

0 Likes 0 ·