Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to load schema file into Cassandra with cqlsh

Tags:

cassandra

cql

I have a schema file for Cassandra. I'm using a windows 7 machine (Cassandra on this machien as well - 1 node). I want to load the schema with cqssh. So far I have not been able to find how. I was hoping to be able to pass the file to cqlsh: cqlsh mySchemaFile. However since I run in windows, to start cqlsh I do the following

python "C:\Program Files (x86)\DataStax Community\apache-cassandra\bin\cqlsh" localhost 9160

Even though I have csqsh in my path, when called like this from python it needs the full path.

I tried to add in there the file name but no luck so far. Is this even possible?

like image 268
Adrian Avatar asked Apr 01 '13 19:04

Adrian


People also ask

How do I import a schema into Cassandra?

You can store the output in a file, then import with 'cassandra-cli -f filename'. If using cqlsh, you can use the 'describe schema' command. You can restrict to a keyspace with 'describe keyspace keyspace'. You can save this to a file then import with 'cqlsh -f filename'.

How do I import data into Cassandra?

If you have data in a file so, you can directly insert your data into the database by using the COPY command in Cassandra. It will be very useful when you have a very large database, and you want to store data quickly and your data is in a CSV file then you can directly insert your data.


1 Answers

cqlsh takes a file to execute via the -f or --file option, not as a positional argument (like the host and port), so the correct form would be:

python "C:\Program Files (x86)\DataStax Community\apache-cassandra\bin\cqlsh" localhost 9160 -f mySchemaFile

Note: I'm not 100% sure about whether you'd use -f or \f in Windows.

like image 195
Tyler Hobbs Avatar answered Nov 15 '22 12:11

Tyler Hobbs