Skip to content

Latest commit

 

History

History

cassandra

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Connecting C++ 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 Pixi

  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 --level user --pre cassandra
  2. Customize the C++ program main.cpp as needed,

    • Change the connection arguments in the AdbcDatabaseSetOption() calls
  3. Build and run the C++ program:

    Using Make:

    pixi run make
    ./cassandra_demo

    Or using CMake:

    pixi run cmake -B build
    pixi run cmake --build build
    ./build/cassandra_demo

Clean up

  1. Clean build artifacts:

    Using Make:

    pixi run make clean

    Using CMake:

    rm -rf build
  2. Stop the Docker container running Cassandra:

    docker stop cassandra