Databases for Go multi-tenant AI Apps.
Turso · Docs · Quickstart · SDK Reference · Blog & Tutorials
- 🔌 Works offline with Embedded Replicas
- 🌎 Works with remote Turso databases
- ✨ Works with Turso AI & Vector Search
- 🐘 Works Go PDO
Warning
This SDK is currently in technical preview. Join us in Discord to report any issues.
go get github.com/tursodatabase/go-libsql
Note
If you require a remote only, no-CGO Go libSQL driver, see libsql-client-go
.
Note
Currently only linux amd64
, linux arm64
, darwin amd64
and darwin arm64
are supported.
The example below uses Embedded Replicas and syncs data every one minute from Turso.
package main
import (
"database/sql"
"fmt"
"os"
"path/filepath"
"github.com/tursodatabase/go-libsql"
)
func main() {
dbName := "local.db"
primaryUrl := "TURSO_DATABASE_URL"
authToken := "TURSO_AUTH_TOKEN"
syncInterval := time.Minute
dir, err := os.MkdirTemp("", "libsql-*")
if err != nil {
fmt.Println("Error creating temporary directory:", err)
os.Exit(1)
}
defer os.RemoveAll(dir)
dbPath := filepath.Join(dir, dbName)
connector, err := libsql.NewEmbeddedReplicaConnector(dbPath, primaryUrl,
libsql.WithAuthToken(authToken),
libsql.WithSyncInterval(syncInterval),
)
if err != nil {
fmt.Println("Error creating connector:", err)
os.Exit(1)
}
defer connector.Close()
db := sql.OpenDB(connector)
defer db.Close()
}
Visit our official documentation.
Join us on Discord to get help using this SDK. Report security issues via email.
See the contributing guide to learn how to get involved.