Implement spellfix

This commit is contained in:
2024-08-13 17:10:28 +02:00
parent 6bfd5cc26a
commit 1983c6c932
2 changed files with 89 additions and 11 deletions

12
db.go
View File

@@ -6,7 +6,7 @@ import (
"log"
"time"
_ "github.com/mattn/go-sqlite3"
"github.com/mattn/go-sqlite3"
)
type DB struct {
@@ -21,7 +21,11 @@ func (db *DB) Open() error {
return fmt.Errorf("database path not set")
}
writeConn, err := sql.Open("sqlite3", db.path+"?_journal=WAL&_synchronous=NORMAL")
sql.Register("spellfixlite", &sqlite3.SQLiteDriver{
Extensions: []string{"spellfix"},
})
writeConn, err := sql.Open("spellfixlite", db.path+"?_journal=WAL&_synchronous=NORMAL")
if err != nil {
Error.Printf("%++v", err)
return err
@@ -31,7 +35,7 @@ func (db *DB) Open() error {
writeConn.SetConnMaxLifetime(30 * time.Second)
db.writeConn = writeConn
readConn, err := sql.Open("sqlite3", db.path+"?mode=ro&_journal=WAL&_synchronous=NORMAL&_mode=ro")
readConn, err := sql.Open("spellfixlite", db.path+"?mode=ro&_journal=WAL&_synchronous=NORMAL&_mode=ro")
if err != nil {
Error.Printf("%++v", err)
return err
@@ -79,7 +83,7 @@ func (db *DB) Init(ddl string) error {
if _, ok := rows[table]; !ok {
log.Printf("Table %s not found, initializing", table)
needsInit = true
break;
break
}
}