Hi,
If I understood the question correctly and you are providing a keyspace that does not yet exists on the client options, something like this:
const createKsQuery = "CREATE KEYSPACE samplekeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }";
const client = new Client({
contactPoints: contactPoints,
keyspace: 'samplekeyspace'
});
client
.connect()
.then(() => client.execute(createKsQuery));
Then, it will fail because you are trying to connect initially to a keyspace that does not yet exists...
You should not provide a keyspace and issue a USE statement after the keyspace has been created, something like this:
// Do not provide the keyspace here
const client = new Client({ contactPoints: contactPoints });
client
.connect()
.then(() => client.execute(createKsQuery))
.then(() => client.execute("USE samplekeyspace"));
This way, all the connections in the pool will switch to samplekeyspace as the active keyspace.
Does it answer your question?
Jorge