{"id":13695810,"url":"https://github.com/IMSMWU/RClickhouse","last_synced_at":"2025-05-03T13:33:32.235Z","repository":{"id":19096344,"uuid":"84608223","full_name":"IMSMWU/RClickhouse","owner":"IMSMWU","description":"A 'DBI' Interface to the Clickhouse Database Providing Basic 'dplyr' Support","archived":false,"fork":false,"pushed_at":"2025-02-27T00:52:56.000Z","size":38275,"stargazers_count":94,"open_issues_count":25,"forks_count":26,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-28T19:40:49.686Z","etag":null,"topics":["clickhouse","clickhouse-database","dbi-interface","dplyr","dplyr-sql-backends","r"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IMSMWU.png","metadata":{"files":{"readme":"Readme.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-10T23:08:47.000Z","updated_at":"2025-03-22T11:02:56.000Z","dependencies_parsed_at":"2025-02-22T01:25:29.798Z","dependency_job_id":"593121e6-c6ad-4fcd-88c1-96df7aecdb72","html_url":"https://github.com/IMSMWU/RClickhouse","commit_stats":{"total_commits":536,"total_committers":44,"mean_commits":"12.181818181818182","dds":0.7257462686567164,"last_synced_commit":"e9ba19f45b17d86743d474809b20d9af37ee206b"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IMSMWU%2FRClickhouse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IMSMWU%2FRClickhouse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IMSMWU%2FRClickhouse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IMSMWU%2FRClickhouse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IMSMWU","download_url":"https://codeload.github.com/IMSMWU/RClickhouse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252173257,"owners_count":21705994,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clickhouse","clickhouse-database","dbi-interface","dplyr","dplyr-sql-backends","r"],"created_at":"2024-08-02T18:00:33.711Z","updated_at":"2025-05-03T13:33:31.833Z","avatar_url":"https://github.com/IMSMWU.png","language":"C++","funding_links":[],"categories":["Language bindings","C++"],"sub_categories":["R"],"readme":"# RClickhouse\n\n![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg) ![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](https://img.shields.io/github/release/IMSMWU/RClickhouse.svg) [![Build Status](https://travis-ci.org/IMSMWU/RClickhouse.svg?branch=master)](https://travis-ci.org/IMSMWU/RClickhouse)\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/RClickhouse)](https://cran.r-project.org/package=RClickhouse)\n[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/RClickhouse)](https://cran.r-project.org/package=RClickhouse)\n\n## Overview\n\n[ClickHouse \u0026copy;](https://clickhouse.com/) is a high-performance relational column-store database to enable big data exploration and 'analytics' scaling to petabytes of data. Methods are provided that enable working with 'Yandex Clickhouse' databases via 'DBI' methods and using 'dplyr'/'dbplyr' idioms.\n\nThis R package is a DBI interface for the Yandex Clickhouse database. It provides basic dplyr support by auto-generating SQL-commands using dbplyr and is based on the official [C++ Clickhouse Client](https://github.com/ClickHouse/clickhouse-cpp).\n\nTo cite this library, please use the BibTeX entry provided in **inst/CITATION**.\n\n\n## Installation\nThis package is available on CRAN, and thus installable by running:\n\n```R\ninstall.packages(\"RClickhouse\")\n```\n\nYou can also install the latest development version directly from github using devtools:\n\n```R\ndevtools::install_github(\"IMSMWU/RClickhouse\")\n```\n\n## Usage\n\n#### Create a DBI Connection:\n\n\u003e *Note:* please be aware that {RClickhouse} doesn't use a HTTP interface in order to communicate with Clickhouse. Thus, You may use the native interface port (by default 9000) instead of the HTTP interface (8123).\n\n\n``` r\ncon \u003c- DBI::dbConnect(RClickhouse::clickhouse(), host=\"example-db.com\")\n```\n\n#### Write data to the database:\n\n``` r\nDBI::dbWriteTable(con, \"mtcars\", mtcars)\n\ndbListTables(con)\ndbListFields(con, \"mtcars\") \n```\n\n#### Query a database using [dplyr](https://dplyr.tidyverse.org/):\n\n``` r\nlibrary(dplyr)\ntbl(con, \"mtcars\") %\u003e% \n  group_by(cyl) %\u003e% \n  summarise(smpg=sum(mpg))\n  \ntbl(con, \"mtcars\") %\u003e% \n  filter(cyl == 8, vs == 0) %\u003e% \n  group_by(am) %\u003e% \n  summarise(mean(qsec))\n\n# Close the connection\ndbDisconnect(con)\n```\n\n#### Query a database using [SQL-style commands](https://www.codecademy.com/articles/sql-commands) with `DBI::dbGetQuery`:\n\n``` r\nDBI::dbGetQuery(con, \"SELECT\n                             vs\n                            ,COUNT(*) AS 'number of cases'\n                            ,AVG(qsec) AS 'average qsec'\n                      FROM mtcars\n                      GROUP BY vs\")\n\n# Save results of querying:\nres \u003c- DBI::dbGetQuery(con, \"SELECT (*)\n                             FROM mtcars\n                             WHERE am = 1\")\n\n# Or save the whole set of data (only useful for smaller datasets, for better performance and for larger datasets always use remote servers):\nmtcars \u003c- dbReadTable(con, mtcars)\n\n# Close the connection\ndbDisconnect(con)\n```\n\n#### Query a database using [ClickHouse functions](https://clickhouse.yandex/docs/en/query_language/functions/)\n\n``` r\n# Get the names of all the avaliable databases\nDBI::dbGetQuery(con, \"SHOW DATABASES\")\n\n# Get information about the variable names and types\nDBI::dbGetQuery(con, \"DESCRIBE TABLE mtcars\")\n\n# Compact CASE - WHEN - THEN conditionals\nDBI::dbGetQuery(con, \"SELECT multiIf(am='1', 'automatic', 'manual') AS 'transmission'\n                            ,multiIf(vs='1', 'straight', 'V-shaped') AS 'engine' \n                      FROM mtcars\")\n\n# Close the connection\ndbDisconnect(con)\n```\n\n### Config File\nYou may use a config file that is looked up for automatic initialization of the dbConnect parameters.\n\nTo do so, create a yaml file (default ```RClickhouse.yaml```), in at least one directory (default lookup paths of parameter config_paths: ```./RClickhouse.yaml, ~/.R/RClickhouse.yaml, /etc/RClickhouse.yaml```), e.g. ```~/.R/configs/RClickhouse.yaml``` and pass a vector of the corresponding file paths to ```dbConnect``` as ```config_paths``` parameter.\nIn ```RClickhouse.yaml```, you may specify a variable number of parameters (```host, port, db, user, password, compression```) to be initialized using the following format (example):\n```YAML\nhost: example-db.com\nport: 1111\n```\nThe actual initialization of the parameters of ```dbConnect``` follows a hierarchical structure with varying priorities (1 to 3, where 1 is highest):\n 1. Specified input parameters when calling ```dbConnect```. If parameters are unspecified, fall back to (2)\n 2. Parameters specified in ```RClickhouse.yaml```, where the level of priority depends on the position of the path in the config_path input vector (first position, highest priority etc.). If parameters are unspecified, fall back to (3).\n 3. Default parameters (```host=\"localhost\", port = 9000, db = \"default\", user = \"default\", password = \"\", compression = \"lz4\"```).\n\n\n## Acknowledgements\nBig thanks to Kirill Müller, Maxwell Peterson, Artemkin Pavel and Hannes Mühleisen.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIMSMWU%2FRClickhouse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIMSMWU%2FRClickhouse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIMSMWU%2FRClickhouse/lists"}