0

when i am linking up R and Cassandra with the RODBC library, i am getting below error

Warning messages: 1: In RODBC::odbcDriverConnect("DSN=DSN=/usr/share/cassandra/lib/cdata.jdbc.cassandra.jar") : [RODBC] ERROR: state IM012, code 0, message [unixODBC][Driver Manager]DRIVER keyword syntax error 2: In RODBC::odbcDriverConnect("DSN=DSN=/usr/share/cassandra/lib/cdata.jdbc.cassandra.jar") : ODBC connection failed

And my code is there:

library(RODBC)

con <-odbcConnect("DSN=/usr/share/cassandra/lib/cdata.jdbc.cassandra.jar")
Community
  • 1
  • 1
Beyhan Gul
  • 1,191
  • 1
  • 15
  • 25

1 Answers1

2

It looks like the problem is that you're trying to use the CData JDBC Driver with RODBC. We produce separate JDBC and ODBC drivers for Cassandra, but either will allow you access your Cassandra data in R.

You can review this article for connecting to Cassandra in R using our ODBC driver, though I've included the relevant steps below:

  1. Configure the DSN

    If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs.

    Set the Server, Port, and Database connection properties to connect to Cassandra. Additionally, to use internal authentication set the User and Password connection properties.

  2. Load the RODBC Package

    library(RODBC)
    
  3. Create a connection to your Cassandra data, using the name of the DSN you configured above

    conn <- odbcConnect("CData Cassandra Source")
    

Once you've established the connection to your Cassandra data, you can perform all manner of operations in R, including:

  • Schema discovery

    sqlTables(conn)
    
  • Executing SQL queries and view the results

    customer <- sqlQuery(conn, "SELECT City, SUM(TotalDue) FROM Customer GROUP BY City", believeNRows=FALSE, rows_at_time=1)
    View(customer)
    
  • Plot Cassandra data

    par(las=2,ps=10,mar=c(5,15,4,2))
    barplot(customer$TotalDue, main="Cassandra Customer", names.arg = customer$City, horiz=TRUE)
    
Jerod Johnson
  • 764
  • 7
  • 15