First you have to make sure you have the java JDK installed.
In a terminal (ubuntu) do this.
sudo apt-get install default-jdk
Then in RStudio you have to install rJava
and RJDBC
install.packages("rJava")
install.packages("RJDBC")
Finally download the JDBC driver and unzip it to a directory on your system. download link
The zip-file has multiple .jar
files which I parked in my local ~/ch
directory.Now your system should be ready to connect!
(please change Sys.glob("~/ch/*.jar")
to the location where you put your .jar
files)
library(RJDBC)
drv <- JDBC("ru.yandex.clickhouse.ClickHouseDriver",
Sys.glob("~/ch/*.jar"), "`")
conn <- dbConnect(drv, "jdbc:clickhouse://host:8123/dbname")
res <- dbGetQuery(conn, "select * from some_table limit 10;")
res