diff --git a/db/db.go b/db/db.go index c484d9b..579c08d 100644 --- a/db/db.go +++ b/db/db.go @@ -30,7 +30,7 @@ type DB struct { // New creates a new DB object from the given filename. func New(filename string) (*DB, error) { - dsn := fmt.Sprintf("%s?_fk=1&mode=rw", filename) + dsn := fmt.Sprintf("%s?_fk=1&mode=rw&cache=shared&_journal=WAL", filename) sqlxdb, err := sqlx.Open("sqlite3", dsn) if err != nil { return nil, errors.WithStack(err) @@ -43,6 +43,7 @@ func New(filename string) (*DB, error) { DB: sqlxdb, PersistentConn: conn.(*sqlite3.SQLiteConn), } + db.SetMaxOpenConns(1) // Perform migrations, if needed. if err := db.migrate(); err != nil { return nil, err