Connecting R to SQream with ODBC

This article describes how to create a new connection to SQream via the RODBC driver.

This article assumes you have R installed on Windows. The Linux version should be similar, but requires installation of the unixODBC package.

Make sure RODBC is installed

In the R console, type

> library(RODBC)

If this succeeds, skip to the next step. Otherwise, install by typing

> install.packages("RODBC")

and then type

> library(RODBC)

again to verify that the install succeeded.

Create a sample connection for testing

Below is a sample connection flow. Make sure to edit in the correct DSN, as you configured with the Windows ODBC Data Sources tool. In the example below, we connect to an existing DSN named sqream64.

Please note the configuration flag believeNRows=F - this is an important flag, and the ODBC driver will not work properly without it.

In this case, we're checking against a table 't' that has a few int-type columns columns, named xint, xtinyint and so on.

> library("RODBC")
> ch <- odbcConnect("sqream64",believeNRows=F)
> sqlQuery(ch,"select top 5 * from t")
  xint xtinyint xsmallint xbigint 
1    1       82      5067       1 
2    2       14      1756       2 
3    3       91     22356       3 
4    4       84     17232       4 
5    5       13     14315       5 
> close(ch)

If something else appears or you get an error, please contact SQream support.

  • 89
  • 11-Apr-2016
  • 592 Views