You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go database/sql driver based on CGO FREE modernc.org/sqlite, providing high availability for SQLite databases.
Features
Built on the robust foundation of modernc.org/sqlite.
High availability support for SQLite databases.
Replication: Synchronize data across nodes using NATS.
Customize the replication strategy
Leaderless clusters: Read/Write from/to any node. Last-writer wins by default, but you can customize conflict resolutions by implementing ChangeSetInterceptor.
Embedded or External NATS: Choose between an embedded NATS server or an external one for replication.
Easy to integrate with existing Go projects.
Installation
go get github.com/litesql/go-sqlite-ha
Usage
package main
import (
"database/sql"
_ "github.com/litesql/go-sqlite-ha"
)
funcmain() {
db, err:=sql.Open("sqlite-ha", "file:example.db?_journal=WAL&_timeout=5000&replicationURL=nats://broker:4222&name=node0")
iferr!=nil {
panic(err)
}
deferdb.Close()
// Use db to interact with your database
}
Using Connector
package main
import (
"database/sql"
sqliteha "github.com/litesql/go-sqlite-ha"
)
funcmain() {
c, err:=sqliteha.NewConnector("file:example.db?_journal=WAL&_timeout=5000",
ha.WithName("node1"),
ha.WithEmbeddedNatsConfig(&ha.EmbeddedNatsConfig{
Port: 4222,
}))
iferr!=nil {
panic(err)
}
deferc.Close()
db:=sql.OpenDB(c)
deferdb.Close()
// Use db to interact with your database
}