https://github.com/rqlite/rqlite-go-http
A Go client for rqlite, useful on its own or as a foundation for higher-level libraries.
https://github.com/rqlite/rqlite-go-http
Last synced: 7 months ago
JSON representation
A Go client for rqlite, useful on its own or as a foundation for higher-level libraries.
- Host: GitHub
- URL: https://github.com/rqlite/rqlite-go-http
- Owner: rqlite
- License: mit
- Created: 2025-01-30T13:15:42.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2025-06-09T14:15:14.000Z (7 months ago)
- Last Synced: 2025-06-09T15:28:33.675Z (7 months ago)
- Language: Go
- Homepage: https://rqlite.io
- Size: 4.44 MB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rqlite-go-http
[](https://circleci.com/gh/rqlite/rqlite-go-http/tree/master)
[](https://goreportcard.com/report/github.com/rqlite/rqlite-go-http)
[](https://pkg.go.dev/github.com/rqlite/rqlite-go-http)
_rqlite-go-http_ is a Go client for rqlite that interacts directly with the rqlite [HTTP API](https://rqlite.io/docs/api/), providing minimal abstraction. Robust and easy-to-use, it can be used on its own or as a foundation for higher-level libraries.
This library offers support for:
- Executing SQL statements (`INSERT`, `UPDATE`, `DELETE`)
- Running queries (`SELECT`)
- Handling both read and write statements in a single request via the _Unified Endpoint_.
- Backing up and restoring data to your rqlite system
- Booting a rqlite node from a SQLite database file
- Checking node status, diagnostic info, cluster membership, and readiness
- Ability to customize HTTP communications for control over TLS, mutual TLS, timeouts, etc.
Check out the [documentation](https://pkg.go.dev/github.com/rqlite/rqlite-go-http) for more details.
## Installation
```bash
go get github.com/rqlite/rqlite-go-http
```
## Example use
```Go
package main
import (
"context"
"fmt"
rqlitehttp "github.com/rqlite/rqlite-go-http"
)
func main() {
// Create a client pointing to a rqlite node
client, err := rqlitehttp.NewClient("http://localhost:4001", nil)
if err != nil {
panic(err)
}
// Optionally set Basic Auth
client.SetBasicAuth("user", "password")
// Create a table.
resp, err := client.ExecuteSingle(context.Background(), "CREATE TABLE foo (id INTEGER PRIMARY KEY, name TEXT)")
if err != nil {
panic(err)
}
// Insert a record.
resp, err = client.Execute(
context.Background(),
rqlitehttp.SQLStatements{
{
SQL: "INSERT INTO foo(name) VALUES(?)",
PositionalParams: []any{"fiona"},
},
},
)
if err != nil {
panic(err)
}
fmt.Printf("ExecuteResponse: %+v\n", resp)
// Query the newly created table
qResp, err := client.QuerySingle(context.Background(), "SELECT * FROM foo")
if err != nil {
panic(err)
}
fmt.Printf("QueryResponse: %+v\n", qResp)
}
```