2

I am new to Cassandra database, I have created keyspace and table.Then, I would like to execute large number of queries that are saved inside a test.sql file ( I dont want to perform Importing from CSV ). My test.sql file content is looks like this..

INSERT INTO contact_detail (<fields>) VALUES(<values>);
INSERT INTO contact_detail (<fields>) VALUES(<values>);
INSERT INTO contact_detail (<fields>) VALUES(<values>);
INSERT INTO contact_detail (<fields>) VALUES(<values>);

I have saved this file into Cassandra bin directory.

how can i run this file and execute all the insert statement? I need to insert all the values to Cassandra Database, how is that possible?

V A S
  • 3,338
  • 4
  • 33
  • 39

2 Answers2

1

Save the file on the one of the nodes. Then run cqlsh -f <file name> -k <keyspace name> on that node.

For more info check here: http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/cqlsh.html

Roman Tumaykin
  • 1,921
  • 11
  • 11
1

You can use the SOURCE command from inside cqlsh to run any CQL script (file path is relative from you launched the cqlsh command).

G Quintana
  • 4,556
  • 1
  • 22
  • 23