Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Connecting Python and Apache Cassandra with ADBC

Instructions

Tip

If you already have a Cassandra instance running, skip the steps to run Cassandra in a Docker container.

Prerequisites

  1. Install uv

  2. Install dbc

Set up Cassandra

  1. Install Docker

  2. Start a Cassandra instance:

    docker run -d --rm --name cassandra -p 9042:9042 cassandra:latest
  3. Wait for Cassandra to accept connections. This can take a minute or two:

    docker exec cassandra cqlsh -e "DESCRIBE CLUSTER"

    If the command fails, wait a few seconds and run it again.

Connect to Cassandra

  1. Install the Cassandra ADBC driver:

    dbc install --pre cassandra
  2. Customize the Python script main.py as needed

    • Change the connection arguments in db_kwargs
  3. Run the Python script:

    uv run main.py

Clean up

Stop the Docker container running Cassandra:

docker stop cassandra