Tip
If you already have a Cassandra instance running, skip the steps to run Cassandra in a Docker container.
-
Start a Cassandra instance:
docker run -d --rm --name cassandra -p 9042:9042 cassandra:latest
-
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.
-
Install the Cassandra ADBC driver:
dbc install --level user --pre cassandra
-
Customize the C++ program
main.cppas needed,- Change the connection arguments in the
AdbcDatabaseSetOption()calls- Format the URI according to the driver documentation, or keep it as is
- Change the connection arguments in the
-
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 build artifacts:
Using Make:
pixi run make clean
Using CMake:
rm -rf build
-
Stop the Docker container running Cassandra:
docker stop cassandra