the example may include:
create keyspace and columnfamily
insert data
select/get data and show in Console
because I found this http://cassandra.apache.org/doc/cql/CQL.html is hard to me
thank you for attention , I got it http://niranjandubey.blogspot.com/2012/11/cassandra-jdbc-to-perform-crud.html.
But I also need a FILE-read-write example of cassandra (may be using datastax?)
Related
Am trying to export a Cassandra Keyspace plus Data to a file. Is there a cqlsh command that allows the export of all tables + Data at once.?
I used this code to export the keyspace. Now I would like to export all the Data from all the tables into the file.
$ cqlsh -e "DESCRIBE KEYSPACE somekeyspace" > /path/to/somekeyspace.cql
Looking at the DataStax documentation, you should be able to do that using the COPY command as follows (for a single table):
COPY someKeySpace.someTable (someCol1, someCol2)
TO '/path/to/someTable_Col1Col2.csv' WITH HEADER = TRUE;
For all tables, probably you will need to write this code multiple times OR iterate through the tables. You might find this article also useful.
ps. I also found this GitHub repo that seems interesting, but I haven't used it yet myself, so I am suggesting it here for you to maybe give it a try :)
https://github.com/masumsoft/cassandra-exporter
I am trying to add an connection to my cassandra database.
As shown in the examples I added this definition:
#Store(type='cassandra', column.family='StockTable',keyspace='AnalyticsFamily',cassandra.host='localhost')
#IndexBy('volume')
#PrimaryKey('symbol')
define table StockTable (symbol string, price float, volume long);
In the editor I get an red cross as shown in the image below.
Am I missing the cassandra driver on the worker? If yes, how can I add it to the docker image? Or what am I doing wrong?
You have to add the osgi compatible cassandra connectors to {SP_HOME}/lib folder.
Please see https://docs.wso2.com/display/SP4xx/Configuring+Datasources for more details
I'm trying to connect to a Datastax Community Edition server 2.1.2 via JDBC but I keep getting the following error no matter what I try to do, even when issuing a very basic command like select * from system_traces.events;
InvalidRequestException(why:Keyspace 'keyspace1' does not exist)
Issuing that same command via cqlsh works properly, so it seems to be a JDBC issue.
InvalidRequestException(why:Keyspace 'keyspace1' does not exist)
at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(CassandraConnection.java:229):229
at org.apache.cassandra.cql.jdbc.CassandraDriver.connect(CassandraDriver.java:92):92
at java.sql.DriverManager.getConnection(DriverManager.java:664):664
at java.sql.DriverManager.getConnection(DriverManager.java:270):270
at railo.commons.db.DBUtil.getConnection(DBUtil.java:109):109
at railo.runtime.db.DatasourceConnectionPool.loadDatasourceConnection(DatasourceConnectionPool.java:89):89
at railo.runtime.db.DatasourceConnectionPool.getDatasourceConnection(DatasourceConnectionPool.java:81):81
at railo.runtime.db.DatasourceManagerImpl.getConnection(DatasourceManagerImpl.java:65):65
at railo.runtime.tag.Query.executeDatasoure(Query.java:696):696 ...
Any ideas? TIA!
InvalidRequestException(why:Keyspace 'keyspace1' does not exist)
This exception means you are trying to query for a keyspace (in this case "Keyspace1") that hasn't yet been added to Cassandra. Try creating the keyspace before querying it.
You're probably doing a select (SELECT * FROM "Keyspace1"."Standard1") that you're not seeing or passing initialisation parameters to JDBC telling it to connect to Keyspace1. Verify that your code isn't looking for the non-existent keyspace by searching through the queries you have, specifically looking for Keyspace1 (or "Keyspace1" since in this case the keyspace name is case-sensitive).
On a side-note, "Keyspace1"."Standard1" tend to be the standard ks.cf pair used for cassandra examples so it would be good to scan your code for them to make sure that they are created before they are queried.
I followed this Tutorial and managed to create 'ContactsList' keyspace at the server with cassandra-cli. However, when I am trying to describe the following keyspace, I am getting strange error:
[default#unknown] describe keyspace ContactList;
Syntax error at position 9: no viable alternative at input 'keyspace'
I am using Apache Cassandra 1.1 (Documentation of "describe keyspace" is here)
Thank you for the help.
Those docs are for CQL, which you can use on the command line with cqlsh.
If you want to use cassandra-cli, the syntax is describe <keyspacename>; i.e. without the 'keyspace'.
I have some questions about Cassandra, first of all i want to create columns and keyspaces in the storage-conf.xml, (which i dont have but i think that cassandra.yaml replaced that in the latest version)
I tried to write this in the cassandra.yaml by opening it in notepad, but it didnt seem to work since i couldnt see my new keyspace in datastax web interface.
<Keyspace>
<Keyspace Name="Sales">
<ColumnFamily Name="Customer" CompareWith="UTF8Type" />
<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy
</ReplicaPlacementStrategy>
<ReplicationFactor>1</ReplicationFactor
<EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
</Keyspace>
What am i doing wrong?
I also wonder if there is a somehow easy way to migrate a relational sql server database in to cassandra?
Thanks in advance!
You are trying to create a keyspace and column by adding the above to cassandra.yaml you cant do that. Second of all what you are adding really doesn't make sense, cassandra.yaml is a YAML file, and the above is XML markup. Cassandra.yaml is for configuration only. If you want to add keyspaces/columns you are going to have to use a cassadra interface (cassandra APIs).
As for the migration, is there an easy way? No not really. B̶u̶t̶ ̶w̶i̶t̶h̶ ̶l̶o̶t̶s̶ ̶o̶f̶ ̶d̶e̶n̶o̶r̶m̶a̶l̶i̶z̶a̶t̶i̶o̶n̶ ̶a̶n̶d̶ ̶r̶e̶s̶e̶a̶r̶c̶h̶ ̶i̶t̶ ̶c̶a̶n̶ ̶b̶e̶ ̶d̶o̶n̶e̶.̶ ̶H̶e̶r̶e̶ ̶i̶s̶ ̶a̶ ̶[̶b̶l̶o̶g̶]̶[̶5̶]̶ ̶t̶h̶a̶t̶ ̶g̶o̶e̶s̶ ̶o̶v̶e̶r̶ ̶a̶ ̶b̶a̶s̶i̶c̶ ̶w̶a̶y̶ ̶o̶f̶ ̶a̶t̶t̶e̶m̶p̶t̶i̶n̶g̶ ̶t̶o̶ ̶d̶o̶ ̶s̶o̶.
Update
The blog is gone 😞. This tutorial by oreilly provides a good overview of how a typical RDMS data model can be modified for Cassandra.