{"id":18574455,"url":"https://github.com/proofrock/ws4sqlite-client-go","last_synced_at":"2025-04-10T08:30:33.922Z","repository":{"id":57654798,"uuid":"454940224","full_name":"proofrock/ws4sqlite-client-go","owner":"proofrock","description":"Go(lang) client for ws4sqlite","archived":false,"fork":false,"pushed_at":"2023-02-09T09:03:11.000Z","size":45545,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T18:44:34.865Z","etag":null,"topics":["go","sqlite","ws4sqlite"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/proofrock.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":"2022-02-02T21:23:50.000Z","updated_at":"2024-06-19T05:58:58.000Z","dependencies_parsed_at":"2024-06-19T05:19:56.180Z","dependency_job_id":"f83830f0-4d85-45bc-ae82-4f3f79a64c36","html_url":"https://github.com/proofrock/ws4sqlite-client-go","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proofrock%2Fws4sqlite-client-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proofrock%2Fws4sqlite-client-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proofrock%2Fws4sqlite-client-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proofrock%2Fws4sqlite-client-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/proofrock","download_url":"https://codeload.github.com/proofrock/ws4sqlite-client-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248185145,"owners_count":21061464,"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":["go","sqlite","ws4sqlite"],"created_at":"2024-11-06T23:15:27.482Z","updated_at":"2025-04-10T08:30:32.200Z","avatar_url":"https://github.com/proofrock.png","language":"Go","readme":"# 🌱 ws4sqlite client for Go(lang)\n\n[pkg.go.dev Docs](https://pkg.go.dev/github.com/proofrock/ws4sqlite-client-go)\n\nThis is an implementation of a client for [ws4sqlite](https://github.com/proofrock/ws4sqlite) to use with Go. It adds convenience to the communication, by not having to deal with JSON, by performing checks for the requests being well formed and by mapping errors to JDK's exceptions.\n\n## Compatibility\n\nCompatibility is guaranteed as follows:\n\n| ws4sqlite version                | this library version |\n|----------------------------------|----------------------|\n| 0.11.x, 0.12.x, 0.13.x (current) | 0.11.x (current)     |\n\nThe library is \"marked\" for Go 1.19 or higher.\n\n## Import\n\n```bash\ngo get github.com/proofrock/ws4sqlite-client-go\n```\n\n# Usage\n\nThis is a translation in Go code of the \"everything included\" request documented in [the docs](https://germ.gitbook.io/ws4sqlite/documentation/requests). It shows the usage, overall; please refer to the [go docs]() for details.\n\n```go\nimport ws4 \"github.com/proofrock/ws4sqlite-client-go\"\n\n//...\n\n// Prepare a client for the transmission. Not thread safe, but cheap to build.\ncli, err := ws4.NewClientBuilder().\n\tWithURL(\"http://localhost:12321/db2\").\n\tWithInlineAuth(\"myUser1\", \"myHotPassword\").\n\tBuild()\n\nif err != nil {\n\tpanic(err)\n}\n\n// Prepare the request, adding different queries/statements. See the docs for a\n// detailed explanation, should be fairly 1:1 to the request at\n// https://germ.gitbook.io/ws4sqlite/documentation/requests\nreq, err := ws4.NewRequestBuilder().\n\tAddQuery(\"SELECT * FROM TEMP\").\n\t//\n\tAddQuery(\"SELECT * FROM TEMP WHERE ID = :id\").\n\tWithValues(map[string]interface{}{\"id\": 1}).\n\t//\n\tAddStatement(\"INSERT INTO TEMP (ID, VAL) VALUES (0, 'ZERO')\").\n\t//\n\tAddStatement(\"INSERT INTO TEMP (ID, VAL) VALUES (:id, :val)\").\n\tWithNoFail().\n\tWithValues(map[string]interface{}{\"id\": 1, \"val\": \"a\"}).\n\t//\n\tAddStatement(\"#Q2\").\n\tWithValues(map[string]interface{}{\"id\": 2, \"val\": \"b\"}).\n\tWithValues(map[string]interface{}{\"id\": 3, \"val\": \"c\"}).\n\t//\n\tBuild()\n\nif err != nil {\n\tpanic(err)\n}\n\n// Call ws4sqlite, obtaining a response and the status code (and a possible error)\n// Status code is !=0 if the method got a response from ws4sqlite, regardless of errors.\nres, code, err := cli.Send(req)\n\n// Code is 200?\nif code != 200 {\n\tpanic(\"There was an error, and now err can be cast to WsError\")\n}\n\nif err != nil {\n\twserr := err.(ws4.WsError)\n\t// Error possibly raised by the processing of the request.\n\t// It contains the same fields from\n\t// https://germ.gitbook.io/ws4sqlite/documentation/errors#global-errors\n\tfmt.Printf(\"HTTP Code: %d\\n\", wserr.Code)\n\tfmt.Printf(\"At subrequest: %d\\n\", wserr.RequestIdx)\n\tfmt.Printf(\"Error: %s\\n\", wserr.Msg) // or wserr.Error()\n\tpanic(\"see above\")\n}\n\n// Unpacking of the response. Every ResponseItem matches a node of the request,\n// and each one has exactly one of the following fields populated:\n// - Error: reason for the error, if it wasn't successful;\n// - RowsUpdated: if the node was a statement and no batching was involved;\n//                it's the number of updated rows;\n// - RowsUpdatedBatch: if the node was a statement and a batch of values was\n//                     provided; it's a slice of the numbers of updated rows\n//                     for each batch item;\n// - ResultSet: if the node was a query; it's a slice of maps with an item\n//              per returned record, and each map has the name of the filed\n//              as a key of each entry, and the value as a value.\nfmt.Printf(\"Number of responses: %d\\n\", len(res.Results))\n\nfmt.Printf(\"Was 1st response successful? %t\\n\", res.Results[0].Success)\n\nfmt.Printf(\"How many records had the 1st response? %d\\n\", len(res.Results[0].ResultSet))\n\nfmt.Printf(\"What was the first VAL returned? %s\\n\", res.Results[0].ResultSet[0][\"VAL\"])\n```\n\nThe encryption extension is supported and [documented](https://pkg.go.dev/github.com/proofrock/ws4sqlite-client-go#RequestBuilder.WithDecoder). \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproofrock%2Fws4sqlite-client-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fproofrock%2Fws4sqlite-client-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproofrock%2Fws4sqlite-client-go/lists"}