Search code examples
rdataframeclickhouse

connect to clickhouse DB in R programming


due to RClickhouse package is deprecate so i change to use clickhouse R DBI client but it still doesn't work when i change port to 9009 and below is my code

library(DBI)
con <- dbConnect(clickhouse::clickhouse(),host="myhost",port=myport,user="my_user",password="my_paswor")

this the error

<simpleError in .local(conn, statement, ...): Port 9000 is for clickhouse-client program You must use port 8123 for HTTP.


Solution

  • You should use 8123 port

    8123 -- ClickHouse http protocol (8443 https)

    9000 -- ClickHouse tcp protocol (9440 tcp/tls)

    9009 -- ClickHouse replication protocol (replicas interconnect)

    https://github.com/IMSMWU/RClickhouse -- uses Native tcp proto (9000)

    https://github.com/hannesmuehleisen/clickhouse-r -- uses HTTP proto (8123)

    Different libraries and applications implement different protocols.