node.jscassandradatastaxcassandra-3.0datastax-node-driver

Cassandra Datastax Node.js driver can't find keyspace


Just installed Cassandra (3.11.1) and Datastax node.js driver (3.3.0).

Created a simple structure:

CREATE KEYSPACE CaseBox
   WITH REPLICATION={
     'class': 'SimpleStrategy',
     'replication_factor': 1};
USE CaseBox;

CREATE TABLE Regions (
    regionId int,
    name varchar,
    PRIMARY KEY ((regionId))
);

Trying connect to the keyspace with no success:

const client = new cassandra.Client({
  contactPoints: ['localhost'],
  keyspace: 'CaseBox'
});

await client.connect();

Error: Keyspace 'CaseBox' does not exist. If I change the desired kayspace to system it works. What's wrong? Please assist.

You can find my full Cassandra config, CQL and js scripts here.


Solution

  • Keyspace names are forced lower case when unquoted in CQL.

    Use CREATE KEYSPACE "CaseBox" in CQL or keyspace: 'casebox' in Node.

    Generally just use snake_case names as you won't get trapped like this as often.