{"id":17570572,"url":"https://github.com/chdb-io/chdb-go","last_synced_at":"2025-04-06T18:14:20.039Z","repository":{"id":213931815,"uuid":"734972901","full_name":"chdb-io/chdb-go","owner":"chdb-io","description":"Go bindings and cli for chDB, an in-process SQL OLAP Engine powered by ClickHouse","archived":false,"fork":false,"pushed_at":"2025-03-24T02:47:23.000Z","size":171,"stargazers_count":99,"open_issues_count":5,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T17:08:46.295Z","etag":null,"topics":["chdb","cli","clickhouse","golang"],"latest_commit_sha":null,"homepage":"https://chdb.io","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/chdb-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":["chdb-io"]}},"created_at":"2023-12-23T07:51:05.000Z","updated_at":"2025-03-28T12:22:31.000Z","dependencies_parsed_at":"2023-12-24T12:26:03.303Z","dependency_job_id":"e4d6595e-9e3e-4b07-9e50-241cdf24a062","html_url":"https://github.com/chdb-io/chdb-go","commit_stats":null,"previous_names":["chdb-io/chdb-go"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdb-io%2Fchdb-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdb-io%2Fchdb-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdb-io%2Fchdb-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdb-io%2Fchdb-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chdb-io","download_url":"https://codeload.github.com/chdb-io/chdb-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247526762,"owners_count":20953143,"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","cli","clickhouse","golang"],"created_at":"2024-10-21T18:01:14.990Z","updated_at":"2025-04-06T18:14:20.022Z","avatar_url":"https://github.com/chdb-io.png","language":"Go","funding_links":["https://github.com/sponsors/chdb-io"],"categories":["Language bindings"],"sub_categories":["Golang"],"readme":"\u003ca href=\"https://chdb.io\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://avatars.githubusercontent.com/u/132536224\" width=130 /\u003e\n\u003c/a\u003e\n\n[![chDB-go](https://github.com/chdb-io/chdb-go/actions/workflows/chdb.yml/badge.svg)](https://github.com/chdb-io/chdb-go/actions/workflows/chdb.yml)\n\n# chdb-go\n[chDB](https://github.com/chdb-io/chdb) go bindings and chDB cli.\n\n## Install\n\n### Install libchdb.so\n1. Install [`libchdb`](https://github.com/chdb-io/chdb/releases)\n  - curl -sL https://lib.chdb.io | bash\n\n### Install chdb-go\n1. Install `chdb-go`\n  - `go install github.com/chdb-io/chdb-go@latest`\n2. Run `chdb-go` with or without persistent `--path`\n  - run `$GOPATH/bin/chdb-go`\n\n### or Build from source\n1. Build `chdb-go`\n  - run `make build`\n2. Run `chdb-go` with or without persistent `--path`\n  - run `./chdb-go`\n\n## chdb-go CLI\n\n1. Simple mode\n```bash\n./chdb-go \"SELECT 123\"\n./chdb-go \"SELECT 123\" JSON\n```\n2. Interactive mode\n```bash\n./chdb-go # enter interactive mode, but data will be lost after exit\n./chdb-go --path /tmp/chdb # interactive persistent mode\n```\n\n```bash\nchdb-io/chdb-go [main] » ./chdb-go \nEnter your SQL commands; type 'exit' to quit.\n :) CREATE DATABASE IF NOT EXISTS testdb;\n\n\n```\n\n#### Go lib Example\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/chdb-io/chdb-go/chdb\"\n)\n\nfunc main() {\n\t// Stateless Query (ephemeral)\n\tresult, err := chdb.Query(\"SELECT version()\", \"CSV\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tfmt.Println(result)\n\n\ttmp_path := filepath.Join(os.TempDir(), \"chdb_test\")\n\t// Stateful Query (persistent)\n\tsession, _ := chdb.NewSession(tmp_path)\n\t// session cleanup will also delete the folder\n\tdefer session.Cleanup()\n\n\t_, err = session.Query(\"CREATE DATABASE IF NOT EXISTS testdb; \" +\n\t\t\"CREATE TABLE IF NOT EXISTS testdb.testtable (id UInt32) ENGINE = MergeTree() ORDER BY id;\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n\t_, err = session.Query(\"USE testdb; INSERT INTO testtable VALUES (1), (2), (3);\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n\tret, err := session.Query(\"SELECT * FROM testtable;\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t} else {\n\t\tfmt.Println(ret)\n\t}\n}\n```\n\n#### Go SQL driver for chDB\n```go\npackage main\n\nimport (\n        \"database/sql\"\n        \"log\"\n\n        _ \"github.com/chdb-io/chdb-go/chdb/driver\"\n)\n\nfunc main() {\n        db, err := sql.Open(\"chdb\", \"\")\n        if err != nil {\n                log.Fatal(err)\n        }\n        rows, err := db.Query(`select COUNT(*) from url('https://datasets.clickhouse.com/hits_compatible/athena_partitioned/hits_0.parquet')`)\n        if err != nil {\n                log.Fatalf(\"select fail, err: %s\", err)\n        }\n        cols, err := rows.Columns()\n        if err != nil {\n                log.Fatalf(\"get result columns fail, err: %s\", err)\n        }\n        log.Printf(\"result columns: %v\", cols)\n        defer rows.Close()\n        var count int\n        for rows.Next() {\n                err := rows.Scan(\u0026count)\n                if err != nil {\n                        log.Fatalf(\"scan fail, err: %s\", err)\n                }\n                log.Printf(\"count: %d\", count)\n        }\n}\n```\n\n### Golang API docs\n\n- See [lowApi.md](lowApi.md) for the low level APIs.\n- See [chdb.md](chdb.md) for high level APIs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchdb-io%2Fchdb-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchdb-io%2Fchdb-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchdb-io%2Fchdb-go/lists"}