Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to submit a CQL script to a cassandra cluster via the datastax driver?

Simply put, I have a cql script I would like to submit to a cluster via the cassandra Session, without having to go through cqlsh.

I've looked through their API and I don't see anything to take in a CQL script, or a way to parse a script into Statements that could be fed into a cassandra Session.

I suppose I could write something that parses the script myself but surely that must exist already somewhere in the datastax code.

like image 437
adapt-dev Avatar asked Dec 10 '15 23:12

adapt-dev


People also ask

What is Cassandra driver?

A modern, feature-rich and highly tunable Node. js client library for Apache Cassandra and DSE using exclusively Cassandra's binary protocol and Cassandra Query Language.


1 Answers

I haven't noticed a function to execute a script, but you could write a little loop to read in your script line by line and call:

session.execute(cql_line);

Where cql_line is a string containing a CQL statement. As long as your script has a complete CQL statement on each line you wouldn't need to do any parsing.

like image 65
Jim Meyer Avatar answered Nov 13 '22 17:11

Jim Meyer