DataStax Astra Developer Hub

Welcome to the DataStax Astra Developer Hub. You'll find comprehensive guides and documentation to help you start working with DataStax Astra as quickly as possible. Use the included APIs to create, modify, and terminate databases, and interact with the databases you create. Let's do it!

Get Started    API Reference

Migrating your DataStax Python driver to connect with Astra databases

Complete the following procedure to migrate your existing DataStax Python driver to a version that is capable of connecting to Astra databases created using DataStax Astra.

Prerequisites

  1. Create a database using DataStax Astra.
  2. Download the secure connect bundle to obtain connection credentials for your DataStax Astra database.

📘

Tip

Alternatively, have a teammate provide access to their Astra database.

Procedure

  1. Install the DataStax Python driver:
pip install cassandra-driver
pip install dse-driver

See the Python driver installation instructions for more information.

  1. Verify that the DataStax Python driver installed successfully:
python -c 'import cassandra; print cassandra.__version__'
python -c 'import dse; print dse.__version__'

The version number displays in the console output:
3.20.0

  1. In your existing DataStax Python driver code, modify the connection code to use the DataStax Astra API.
    In the cloud_config parameter, include the path to the secure connect bundle for your Astra database (secure-connect-*database_name*.zip), as shown in the following example.
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider

cloud_config= {
        'secure_connect_bundle': '/path/to/secure-connect-database_name.zip'
}
auth_provider = PlainTextAuthProvider('username', 'password')
cluster = Cluster(cloud=cloud_config, auth_provider=auth_provider)
session = cluster.connect()
from dse.cluster import Cluster
from dse.auth import PlainTextAuthProvider

cloud_config = {
   'secure_connect_bundle': '/python_project/creds/secure-connect-database_name.zip'
}
auth_provider = PlainTextAuthProvider(username='username', 'password')
cluster = Cluster(cloud=cloud_config, auth_provider=auth_provider)
session = cluster.connect()
  1. Run your Python script to connect to your Astra database.
    $ python ./my_python_driver.py
    If successful, the code builds, compiles, and connects to your Cassandra database.

Updated 14 days ago


Migrating your DataStax Python driver to connect with Astra databases


Complete the following procedure to migrate your existing DataStax Python driver to a version that is capable of connecting to Astra databases created using DataStax Astra.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.