mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
refactor: change back to modernc sqlite db driver (#120)
* refactor: change to modernc sqlite db driver * chore: update deps
This commit is contained in:
parent
18f323746a
commit
3c323004c0
5 changed files with 189 additions and 11 deletions
|
@ -6,8 +6,8 @@ import (
|
|||
"fmt"
|
||||
"sync"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/rs/zerolog/log"
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
type SqliteDB struct {
|
||||
|
@ -37,15 +37,15 @@ func (db *SqliteDB) Open() error {
|
|||
var err error
|
||||
|
||||
// open database connection
|
||||
if db.handler, err = sql.Open("sqlite3", db.DSN); err != nil {
|
||||
if db.handler, err = sql.Open("sqlite", db.DSN+"?_pragma=busy_timeout%3d1000"); err != nil {
|
||||
log.Fatal().Err(err).Msg("could not open db connection")
|
||||
return err
|
||||
}
|
||||
|
||||
// Set busy timeout
|
||||
if _, err = db.handler.Exec(`PRAGMA busy_timeout = 5000;`); err != nil {
|
||||
return fmt.Errorf("busy timeout pragma: %w", err)
|
||||
}
|
||||
//if _, err = db.handler.Exec(`PRAGMA busy_timeout = 5000;`); err != nil {
|
||||
// return fmt.Errorf("busy timeout pragma: %w", err)
|
||||
//}
|
||||
|
||||
// Enable WAL. SQLite performs better with the WAL because it allows
|
||||
// multiple readers to operate while data is being written.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue