{"id":13695624,"url":"https://github.com/roistat/go-clickhouse","last_synced_at":"2025-07-28T08:44:53.504Z","repository":{"id":42424122,"uuid":"61634725","full_name":"roistat/go-clickhouse","owner":"roistat","description":"Golang ClickHouse connector","archived":false,"fork":false,"pushed_at":"2024-04-16T14:49:01.000Z","size":53,"stargazers_count":189,"open_issues_count":4,"forks_count":27,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-06-01T12:47:37.337Z","etag":null,"topics":["adapter","clickhouse","client","connector","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roistat.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2016-06-21T13:09:55.000Z","updated_at":"2024-05-07T20:29:43.000Z","dependencies_parsed_at":"2024-04-19T02:32:44.222Z","dependency_job_id":null,"html_url":"https://github.com/roistat/go-clickhouse","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/roistat/go-clickhouse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roistat%2Fgo-clickhouse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roistat%2Fgo-clickhouse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roistat%2Fgo-clickhouse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roistat%2Fgo-clickhouse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roistat","download_url":"https://codeload.github.com/roistat/go-clickhouse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roistat%2Fgo-clickhouse/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267488100,"owners_count":24095772,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["adapter","clickhouse","client","connector","go","golang"],"created_at":"2024-08-02T18:00:31.186Z","updated_at":"2025-07-28T08:44:53.445Z","avatar_url":"https://github.com/roistat.png","language":"Go","funding_links":[],"categories":["Language bindings"],"sub_categories":["Golang"],"readme":"# go-clickhouse \n# [![Travis status](https://img.shields.io/travis/roistat/go-clickhouse.svg)](https://travis-ci.org/roistat/go-clickhouse) [![Coverage Status](https://img.shields.io/coveralls/roistat/go-clickhouse.svg)](https://coveralls.io/github/roistat/go-clickhouse) [![Go Report](https://goreportcard.com/badge/github.com/roistat/go-clickhouse)](https://goreportcard.com/report/github.com/roistat/go-clickhouse) ![](https://img.shields.io/github/license/roistat/go-clickhouse.svg)\n\nGolang [Yandex ClickHouse](https://clickhouse.yandex/) connector\n\nClickHouse manages extremely large volumes of data in a stable and sustainable manner.\nIt currently powers Yandex.Metrica, world’s second largest web analytics platform,\nwith over 13 trillion database records and over 20 billion events a day, generating\ncustomized reports on-the-fly, directly from non-aggregated data. This system was\nsuccessfully implemented at CERN’s LHCb experiment to store and process metadata on\n10bn events with over 1000 attributes per event registered in 2011.\n\n## Examples\n\n#### Query rows\n\n```go\nconn := clickhouse.NewConn(\"localhost:8123\", clickhouse.NewHttpTransport())\nquery := clickhouse.NewQuery(\"SELECT name, date FROM clicks\")\niter := query.Iter(conn)\nvar (\n    name string\n    date string\n)\nfor iter.Scan(\u0026name, \u0026date) {\n    //\n}\nif iter.Error() != nil {\n    log.Panicln(iter.Error())\n}\n```\n\n#### Single insert\n```go\nconn := clickhouse.NewConn(\"localhost:8123\", clickhouse.NewHttpTransport())\nquery, err := clickhouse.BuildInsert(\"clicks\",\n    clickhouse.Columns{\"name\", \"date\", \"sourceip\"},\n    clickhouse.Row{\"Test name\", \"2016-01-01 21:01:01\", clickhouse.Func{\"IPv4StringToNum\", \"192.0.2.192\"}},\n)\nif err == nil {\n    err = query.Exec(conn)\n    if err == nil {\n        //\n    }\n}\n```\n\n#### External data for query processing\n\n[See documentation for details](https://clickhouse.yandex/reference_en.html#External%20data%20for%20query%20processing) \n\n```go\nconn := clickhouse.NewConn(\"localhost:8123\", clickhouse.NewHttpTransport())\nquery := clickhouse.NewQuery(\"SELECT Num, Name FROM extdata\")\nquery.AddExternal(\"extdata\", \"Num UInt32, Name String\", []byte(\"1\tfirst\\n2\tsecond\")) // tab separated\n\n\niter := query.Iter(conn)\nvar (\n    num  int\n    name string\n)\nfor iter.Scan(\u0026num, \u0026name) {\n    //\n}\nif iter.Error() != nil {\n    log.Panicln(iter.Error())\n}\n```\n\n## Cluster\n\nCluster is useful if you have several servers with same `Distributed` table (master). In this case you can send\nrequests to random master to balance load.\n\n* `cluster.Check()` pings all connections and filters active ones\n* `cluster.ActiveConn()` returns random active connection\n* `cluster.OnCheckError()` is called when any connection fails\n\n**Important**: You should call method `Check()` at least once after initialization, but we recommend\nto call it continuously, so `ActiveConn()` will always return filtered active connection.\n\n```go\nhttp := clickhouse.NewHttpTransport()\nconn1 := clickhouse.NewConn(\"host1\", http)\nconn2 := clickhouse.NewConn(\"host2\", http)\n\ncluster := clickhouse.NewCluster(conn1, conn2)\ncluster.OnCheckError(func (c *clickhouse.Conn) {\n    log.Fatalf(\"Clickhouse connection failed %s\", c.Host)\n})\n// Ping connections every second\ngo func() {\n    for {\n        cluster.Check()\n        time.Sleep(time.Second)\n    }\n}()\n```\n\n## Transport options\n\n### Timeout\n\n```go\nt := clickhouse.NewHttpTransport()\nt.Timeout = time.Second * 5\n\nconn := clickhouse.NewConn(\"host\", t)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froistat%2Fgo-clickhouse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froistat%2Fgo-clickhouse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froistat%2Fgo-clickhouse/lists"}