Reputation: 361
I'm new to Cassandra and R. When I'm connecting to Cassandra database using RCassandra
package, connection is establishing. But When trying to use any keyspace, R is not responding. I used the following statements.
c <- RC.connect('192.168.1.20', 9042)
RC.use(c, 'effesensors')
Please give me a brief idea about how to use RCassandra
to avoid this problem.
Upvotes: 3
Views: 1263
Reputation: 1
I read your comments above, you are using the wrong port. You should run the following command c <- RC.connect('192.168.1.20', 9160) This will definitely work for you.
Upvotes: 0
Reputation: 11
Thanks @D. Venkata Naresh, your suggestion of using RODBC driver resolved my issue.
I am using R and datastax cassandra community edition.
This is the link I followed to configure the ODBC driver in my windows machine.
https://www.datastax.com/dev/blog/using-the-datastax-odbc-driver-for-apache-cassandra
Then, in my R studio, These are the commands to connect and fetch from the Cassandra
install.packages("RODBC")
library("RODBC")
require("RODBC")
conn <- odbcConnect(<ODBC datasource name>)
dataframe <- sqlFetch(conn, <column family / table name>)
dataframe
Hope, this answer helps someone who is facing issue with RCassandra.
Upvotes: 1
Reputation: 361
make use of RODBC instead of using RCassandra. We need to install Cassandra ODBC driver.
Upvotes: 1
Reputation: 3200
Are you aware that you may be using a non default port for Cassandra? If you can provide the Cassandra version and RStudio version I may be able to update my answer. I found this tutorial by tarkalabs useful as a checklist of steps to take before any connection is attempted.
From the tutorial,
Now connect to your database with
connect.handle <- RC.connect(host="127.0.0.1", port=9160)
Cassandra by default listens to port 9160 but you can change it according to your configuration. To show the cluster type into your prompt
RC.cluster.name(connect.handle)
Just to verify that you are connected and your Cassandra instance is running try the following command:
RC.describe.keyspaces(connect.handle)
That should bring back a list of the settings in your keyspaces. If nothing returns, you are either not connected or your Cassandra instance is not properly installed.
EXAMPLE OUTPUT
$system_traces$strategy_options
replication_factor
"2"
$system_traces$cf_defs
named list()
$system_traces$durable_writes
[1] TRUE
Let me know what your results are if my answer does not work and I will update my answer. Good Luck!
Upvotes: 1