{"id":36612942,"url":"https://github.com/machbase/neo-grpc","last_synced_at":"2026-01-12T09:00:50.596Z","repository":{"id":65661942,"uuid":"584237261","full_name":"machbase/neo-grpc","owner":"machbase","description":"client library for machbase-neo","archived":false,"fork":false,"pushed_at":"2024-03-21T01:42:08.000Z","size":232,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-03-21T02:43:47.352Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://neo.machbase.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/machbase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-01-02T00:15:11.000Z","updated_at":"2023-05-09T18:38:25.000Z","dependencies_parsed_at":"2023-10-11T02:49:50.155Z","dependency_job_id":"76750a08-1a18-48e6-a0e2-50bbc1339700","html_url":"https://github.com/machbase/neo-grpc","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/machbase/neo-grpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/machbase%2Fneo-grpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/machbase%2Fneo-grpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/machbase%2Fneo-grpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/machbase%2Fneo-grpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/machbase","download_url":"https://codeload.github.com/machbase/neo-grpc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/machbase%2Fneo-grpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28337611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-01-12T09:00:25.319Z","updated_at":"2026-01-12T09:00:50.555Z","avatar_url":"https://github.com/machbase.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# This repo is archived.(readonly)\n\nMoved to [machbase/neo-client](https://github.com/machbase/neo-client)\n\n# neo-grpc\n\n- `proto` gRPC .proto file specifies API of machbase-neo\n- `machrpc` reference implementation of gRPC client of machbase-neo with helper functions.\n- `driver` implmenetation of go sql/driver based gRPC\n\n## gRPC client for machbase-neo\n\n### Install\n\n```\ngo get -u github.com/machbase/neo-grpc\n```\n\n### How to use\n\n```go\nimport \"github.com/machbase/neo-grpc/machrpc\"\n```\n\n```go\ncli := machrpc.NewClient(\n        machrpc.WithServer(\"127.0.0.1:5655\"),\n        machrpc.WithCertificate(\"/path/to/client_key.pem\", \"/path/to/client_cert.pem\", \"/path/to/server_cert.pem\"),\n        machrpc.WithQueryTimeout(5 * time.Second)\n    )\nif err := cli.Connect(); err != nil {\n    panic(err)\n}\ndefer cli.Disconnect()\n\nsqlText := \"insert into example (name, time, value) values (?, ?, ?)\"\ncli.Exec(sqlText, \"tag-name\", time.Now(), 3.1415)\n```\n\n### protobuf compiler\n\n\u003e https://grpc.io/docs/protoc-installation/\n\n- linux\n\n```\nsudo apt install -y protobuf-compiler\n```\n\n- macOS\n\n```\nbrew install protobuf\n```\n\n- protoc-gen-go plugin\n\n```\ngo install google.golang.org/protobuf/cmd/protoc-gen-go@latest\ngo install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest\n```\n\n## Go Driver for machbase-neo\n\n### Install\n\nTp add driver into your `go.mod`, execute this command on your working directory.\n\n```sh\ngo get -u github.com/machbase/neo-grpc/driver\n```\n\n### Import\n\nAdd import statement in your source file.\n\n```go\nimport (\n    \"database/sql\"\n    _ \"github.com/machbase/neo-grpc/driver\"\n)\n```\n\n\u003e The package name `github.com/machbase/neo-grpc/driver` implies that the driver is implemented over gRPC API of machbase-neo. See [gRPC API](/docs/api-grpc/) for more about it.\n\nLet's load sql driver and connect to server.\n\n```go\ndb, err := sql.Open(\"machbase\", \"127.0.0.1:5655\")\nif err != nil {\n    panic(err)\n}\ndefer db.Close()\n```\n\n`sql.Open()` is called, `machbase` as driverName and second argument is machbase-neo's gRPC address.\n\n### Insert and Query\n\nSince we get `*sql.DB` successfully, write and read data can be done by Go standard sql package.\n\n```go\nvar tag = \"tag01\"\n_, err = db.Exec(\"INSERT INTO EXAMPLE (name, time, value) VALUES(?, ?, ?)\", tag, time.Now(), 1.234)\n```\n\nUse `db.QueryRow()` to count total records of same tag name.\n\n```go\nvar count int\nrow := db.QueryRow(\"SELECT count(*) FROM EXAMPLE WHERE name = ?\", tag)\nrow.Scan(\u0026count)\n```\n\nTo iterate result of query, use `db.Query()` and get `*sql.Rows`.\n\n{{\u003c callout type=\"warning\" \u003e}}\nIt is import not to forget releasing `rows` as soon as possible when you finish the work to prevent leaking resource.\u003cbr/\u003e\nGeneral pattern is using `defer rows.Close()`.\n{{\u003c /callout \u003e}}\n\n```go\nrows, err := db.Query(\"SELECT name, time, value FROM EXAMPLE WHERE name = ? ORDER BY TIME DESC\", tag)\nif err != nil {\n    panic(err)\n}\ndefer rows.Close()\n\nfor rows.Next() {\n    var name string\n    var ts time.Time\n    var value float64\n    rows.Scan(\u0026name, \u0026ts, \u0026value)\n    fmt.Println(\"name:\", name, \"time:\", ts.Local().String(), \"value:\", value)\n}\n```\n\n### Full source code \n\n```go\npackage main\n\nimport (\n\t\"database/sql\"\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"time\"\n\n\tdriver \"github.com/machbase/neo-grpc/driver\"\n)\n\nfunc main() {\n\thomeDir, err := os.UserHomeDir()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tserverAddr := \"127.0.0.1:5655\"\n\tserverCert := filepath.Join(homeDir, \".config\", \"machbase\", \"cert\", \"machbase_cert.pem\")\n\t// This example substitute server's key \u0026 cert for the client's key, cert.\n\t// It is just for the briefness of sample code\n\t// Client applicates **SHOULD** issue a certificate for each one.\n\t// Please refer to the \"API Authentication\" section of the documents.\n\tclientKey := filepath.Join(homeDir, \".config\", \"machbase\", \"cert\", \"machbase_key.pem\")\n\tclientCert := filepath.Join(homeDir, \".config\", \"machbase\", \"cert\", \"machbase_cert.pem\")\n\n\t// register machbase-neo datasource\n\tdriver.RegisterDataSource(\"neo\", \u0026driver.DataSource{\n\t\tServerAddr: serverAddr,\n\t\tServerCert: serverCert,\n\t\tClientKey:  clientKey,\n\t\tClientCert: clientCert,\n\t})\n\n\tdb, err := sql.Open(\"machbase\", \"neo\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer db.Close()\n\n\t// INSERT with Exec\n\ttag := \"tag01\"\n\t_, err = db.Exec(\"INSERT INTO EXAMPLE (name, time, value) VALUES(?, ?, ?)\", tag, time.Now(), 1.234)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// QueryRow\n\trow := db.QueryRow(\"SELECT count(*) FROM EXAMPLE WHERE name = ?\", tag)\n\tif row.Err() != nil {\n\t\tpanic(row.Err())\n\t}\n\tvar count int\n\tif err = row.Scan(\u0026count); err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(\"count:\", count)\n\n\t// Query\n\trows, err := db.Query(\"SELECT name, time, value FROM EXAMPLE WHERE name = ? ORDER BY TIME DESC\", tag)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer rows.Close()\n\n\tfor rows.Next() {\n\t\tvar name string\n\t\tvar ts time.Time\n\t\tvar value float64\n\t\trows.Scan(\u0026name, \u0026ts, \u0026value)\n\t\tfmt.Println(\"name:\", name, \"time:\", ts.Local().String(), \"value:\", value)\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmachbase%2Fneo-grpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmachbase%2Fneo-grpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmachbase%2Fneo-grpc/lists"}