Skip to content

Latest commit

 

History

History

cassandra

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Connecting JavaScript 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 Node.js (version 22 or later)

    • Alternatively, you can use Bun or Deno
  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. Install dependencies:

    npm --prefix .. install
  3. Customize the script main.js as needed

    • Change the connection arguments in databaseOptions
  4. Run the script:

    Node.js:

    node main.js

    Bun:

    bun run main.js

    Deno:

    deno run --allow-ffi --allow-env main.js

Clean up

Stop the Docker container running Cassandra:

docker stop cassandra