TriCoreDB for Go
v0.1.0The official Go client: SQL, documents, cache, vectors and graphs over one native connection.
Install
go
go get github.com/trinesh14/tricoredb-sdk-goRequirements
- Go 1.21 or later
- A TriCoreDB server, 0.1.0-rc.1 or later (install one)
Highlights
- Standard library only
- Typed errors for errors.Is and errors.As
- Transactions, connection pool, TLS and mutual TLS
Quick start
main.go
package main
import (
"context"
"fmt"
"log"
tricoredb "github.com/trinesh14/tricoredb-sdk-go"
)
func main() {
ctx := context.Background()
db, err := tricoredb.Connect(ctx, tricoredb.Options{
Host: "127.0.0.1", Port: 8427, User: "admin", Secret: "your-password",
})
if err != nil {
log.Fatal(err)
}
defer db.Close()
if _, err := db.Execute("CREATE TABLE IF NOT EXISTS users (id INT PRIMARY KEY, name TEXT)"); err != nil {
log.Fatal(err)
}
if _, err := db.ExecuteParams("INSERT INTO users VALUES (?, ?)", 1, "O'Hara"); err != nil {
log.Fatal(err)
}
rows, err := db.QueryParams("SELECT name FROM users WHERE id = ?", 1)
if err != nil {
log.Fatal(err)
}
fmt.Println(rows.Columns, rows.Rows) // [name] [[O'Hara]]
}TLS
This example connects without TLS, which matches the development container. The default image requires TLS. The README shows how to connect with a CA certificate, and documents every call.