{"id":20578073,"url":"https://github.com/timeplus-io/proton-go-driver","last_synced_at":"2025-08-12T15:06:12.553Z","repository":{"id":197881650,"uuid":"471245909","full_name":"timeplus-io/proton-go-driver","owner":"timeplus-io","description":"Go driver for Timeplus Proton","archived":false,"fork":false,"pushed_at":"2025-06-05T08:04:33.000Z","size":2046,"stargazers_count":5,"open_issues_count":15,"forks_count":4,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-06-05T09:19:30.833Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://timeplus.com","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/timeplus-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"zenodo":null}},"created_at":"2022-03-18T05:24:37.000Z","updated_at":"2025-06-05T08:01:34.000Z","dependencies_parsed_at":"2023-10-03T07:03:09.979Z","dependency_job_id":"5dc7a8e4-a20b-43ff-9479-48f76e164be4","html_url":"https://github.com/timeplus-io/proton-go-driver","commit_stats":null,"previous_names":["timeplus-io/proton-go-driver"],"tags_count":84,"template":false,"template_full_name":null,"purl":"pkg:github/timeplus-io/proton-go-driver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timeplus-io%2Fproton-go-driver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timeplus-io%2Fproton-go-driver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timeplus-io%2Fproton-go-driver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timeplus-io%2Fproton-go-driver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timeplus-io","download_url":"https://codeload.github.com/timeplus-io/proton-go-driver/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timeplus-io%2Fproton-go-driver/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270082295,"owners_count":24523709,"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-08-12T02:00:09.011Z","response_time":80,"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":[],"created_at":"2024-11-16T06:10:20.959Z","updated_at":"2025-08-12T15:06:12.500Z","avatar_url":"https://github.com/timeplus-io.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Proton Go Driver\n\n## Introduction\n[Proton](https://github.com/timeplus-io/proton) is a unified streaming and historical data processing engine in a single binary. The historical store is built based on [ClickHouse](https://github.com/ClickHouse/ClickHouse).\n\nThis project provides go driver to interact with Proton, the code is based on https://github.com/ClickHouse/clickhouse-go.\n\n## Installation\n\nTo get started, you need to have Go installed. Then, import the Proton Database Go Driver using Go Modules:\n\n```shell\ngo get github.com/timeplus-io/proton-go-driver/v2\n```\n\n## Quick Start\n\n1. Run proton with docker, `docker run -d -p 8463:8463 --pull always --name proton ghcr.io/timeplus-io/proton:develop`\n2. Run following Golang code\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/timeplus-io/proton-go-driver/v2\"\n)\n\nfunc main() {\n\tconn := proton.OpenDB(\u0026proton.Options{\n\t\tAddr: []string{\"127.0.0.1:8463\"},\n\t\tAuth: proton.Auth{\n\t\t\tUsername: \"default\",\n\t\t\tPassword: \"\",\n\t\t},\n\t})\n\tvar value int\n\tconn.QueryRow(\"SELECT 300\").Scan(\u0026value)\n\tfmt.Println(value)\n}\n```\n\nabove code should return 1 , which shows that everything is working fine now.\n\n## Connecting to Proton Database\n\nTo connect to the Proton database, create a connection using the following code:\n\n```go\nconn := proton.OpenDB(\u0026proton.Options{\n    Addr: []string{\"127.0.0.1:8463\"},\n    Auth: proton.Auth{\n        Database: \"default\",\n        Username: \"default\",\n        Password: \"\",\n    },\n    DialTimeout: 5 * time.Second,\n    Compression: \u0026proton.Compression{\n        proton.CompressionLZ4,\n    },\n})\nconn.SetMaxIdleConns(5)\nconn.SetMaxOpenConns(10)\nconn.SetConnMaxLifetime(time.Hour)\nctx = proton.Context(ctx, proton.WithProgress(func(p *proton.Progress) {\n    if rand.Float32() \u003c 0.3 {\n        log.Println(\"progress:\", p)\n    }\n}))\n```\n\n## Create Stream\n\nBefore working with streaming data, you need to initialize it. Here's an example for creating a stream:\n\n```go\nif _, err := conn.ExecContext(ctx, \"DROP STREAM IF EXISTS car\"); err != nil {\n    return err\n}\nif _, err := conn.ExecContext(ctx, \"CREATE STREAM IF NOT EXISTS car(id int64, speed float64)\"); err != nil {\n    return err\n}\n```\n## Batch Insertion\n\n```go\nscope, err := conn.Begin()\nif err != nil {\n    log.Fatal(err)\n}\nbatch, err := scope.PrepareContext(ctx, \"INSERT INTO car (id, speed, _tp_time) values\")\nfor i := 0; i \u003c 20; i++ {\n    speed := rand.Float64()*20 + 50\n    _, err := batch.Exec(id, speed, time.Now())\n    if err != nil {\n        log.Fatal(err)\n    }\n    time.Sleep(time.Duration(100) * time.Millisecond)\n}\nerr = scope.Commit()\nif err != nil {\n    log.Fatal(err)\n}\n```\n\n## Streaming Query\n\n```go\nconst QueryDDL = `SELECT id, avg(speed), window_start, window_end\n    FROM session(car, 1h, [speed \u003e= 60, speed \u003c 60))\n    GROUP BY id, window_start, window_end`\nconn, ctx := getConnection(context.Background())\nctx, cancel := context.WithCancel(ctx)\nrows, err := conn.QueryContext(ctx, QueryDDL)\nif err != nil {\n    log.Fatal(err)\n}\ndefer rows.Close()\ngo func() {\n    time.Sleep(time.Duration(20) * time.Second)\n    cancel()\n}()\nfor rows.Next() {\n    var car SpeedingCarRcd\n    if err := rows.Scan(\u0026car.Id, \u0026car.Speed, \u0026car.Start, \u0026car.End); err != nil {\n        log.Fatal(err)\n    }\n    log.Printf(\"%+v\", car)\n}\nerr = rows.Err()\nif err != nil {\n    log.Fatal(err)\n}\n```\n\n\u003e [!NOTE]\n\u003e To cancel a streaming query, you need to use the cancel function returned by `context.WithCancel`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimeplus-io%2Fproton-go-driver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimeplus-io%2Fproton-go-driver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimeplus-io%2Fproton-go-driver/lists"}