{"id":25399600,"url":"https://github.com/blackrez/chdb-purego","last_synced_at":"2025-10-08T02:42:37.124Z","repository":{"id":276984687,"uuid":"930950780","full_name":"blackrez/chdb-purego","owner":"blackrez","description":"alternative go binding to chdb (clickhouse on memory) using go","archived":false,"fork":false,"pushed_at":"2025-02-11T13:58:41.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T14:35:33.319Z","etag":null,"topics":["chdb","clickhouse","golang","purego"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blackrez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"blackrez"}},"created_at":"2025-02-11T13:35:07.000Z","updated_at":"2025-02-11T13:58:57.000Z","dependencies_parsed_at":"2025-02-11T20:31:12.372Z","dependency_job_id":null,"html_url":"https://github.com/blackrez/chdb-purego","commit_stats":null,"previous_names":["blackrez/chdb-purego"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blackrez%2Fchdb-purego","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blackrez%2Fchdb-purego/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blackrez%2Fchdb-purego/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blackrez%2Fchdb-purego/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blackrez","download_url":"https://codeload.github.com/blackrez/chdb-purego/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248459354,"owners_count":21107295,"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":["chdb","clickhouse","golang","purego"],"created_at":"2025-02-15T23:38:28.183Z","updated_at":"2025-10-08T02:42:32.076Z","avatar_url":"https://github.com/blackrez.png","language":"Go","funding_links":["https://github.com/sponsors/blackrez"],"categories":[],"sub_categories":[],"readme":"# non-official go binding for chDB (using purego)\n\nIf you are looking for the official golang, it's available at\n\nhttps://github.com/chdb-io/chdb-go\n\nThis go binding don't use cgo for bind chdb.\n\n## Motivations\n\nMy first motivation was to learn purego and facilitate the distribution and usage of the chdb binding.\nFeel free to fork or open an issue.\n\n\n## Installation\n\nYou need to download and decompress libchb.so on your system.\n\nThe download links are on the release page of chdb : \n\nhttps://github.com/chdb-io/chdb/releases/tag/v3.0.0\n```\nlinux-aarch64-libchdb.tar.gz\nlinux-x86_64-libchdb.tar.gz\nmacos-arm64-libchdb.tar.gz\nmacos-x86_64-libchdb.tar.gz\n\n```\n\n\nThe module looks the lib to this path\n\n```\n        \"/usr/local/lib/libchdb.so\",\n        \"/opt/homebrew/lib/libchdb.so\",\n```\n\nor use `CHDB_LIB_PATH` as an environement variable.\n\n\n## Basic usage \n\nInstall the go module\n\nLike the API of chdb, it has 2 methods \n\n```\n\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/blackrez/chdb-purego\"\n)\n\n\nfunc main() {\n    conn, err := chdb.Connect(\":memory:\")\n    if err != nil {\n        panic(err)\n    }\n    defer conn.Close()\n    q := `\n    SELECT\n    floor(randNormal(100, 5)) AS k,\n    count(*) AS c,\nFROM numbers(10) GROUP BY k ORDER BY k ASC \n    `\n    result := conn.Query(q, \"JSON\")\n    defer result.Free()\n    \n    fmt.Println(string(result.Data))\n}\n```\n\n\nThen run \n\n```\nCHDB_LIB_PATH=\"/$HOME/chdb-purego/libchdb.so\" go run main.go\n```\n\n```\n(base) nabil in ~/project/chdb-purego/example λ CGO_ENABLED=0 CHDB_LIB_PATH=\"/Users/nabil/project/chdb-purego/libchdb.so\" go run main.go\n{\n\t\"meta\":\n\t[\n\t\t{\n\t\t\t\"name\": \"k\",\n\t\t\t\"type\": \"Float64\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"c\",\n\t\t\t\"type\": \"UInt64\"\n\t\t}\n\t],\n\n\t\"data\":\n\t[\n\t\t{\n\t\t\t\"k\": 91,\n\t\t\t\"c\": 1\n\t\t},\n\t\t{\n\t\t\t\"k\": 94,\n\t\t\t\"c\": 1\n\t\t},\n\t\t{\n\t\t\t\"k\": 99,\n\t\t\t\"c\": 3\n\t\t},\n\t\t{\n\t\t\t\"k\": 102,\n\t\t\t\"c\": 1\n\t\t},\n\t\t{\n\t\t\t\"k\": 104,\n\t\t\t\"c\": 1\n\t\t},\n\t\t{\n\t\t\t\"k\": 106,\n\t\t\t\"c\": 3\n\t\t}\n\t],\n\n\t\"rows\": 6,\n\n\t\"statistics\":\n\t{\n\t\t\"elapsed\": 0.0226755,\n\t\t\"rows_read\": 0,\n\t\t\"bytes_read\": 0\n\t}\n}\n```\n\n\n## Roadmap :\n\n\nThe objective is to add the support of chproto https://github.com/ClickHouse/ch-go/tree/main/proto for an easier data exchange between go and clickhouse.\n\n- [ ] more tests\n- [ ] add chproto support\n- [ ] better handling lib path\n- [ ] test (and support) persistent sessions\n- [ ] add sql interface\n- [ ] add optionnal go-arrow binding\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackrez%2Fchdb-purego","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblackrez%2Fchdb-purego","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackrez%2Fchdb-purego/lists"}