Implement spellfix
This commit is contained in:
12
db.go
12
db.go
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user