Skip to content

Commit

Permalink
Fix 'database is locked' error
Browse files Browse the repository at this point in the history
  • Loading branch information
cerblue authored and nonsense committed Aug 4, 2022
1 parent c8f9868 commit 5832992
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ type Scannable interface {
}

func SqlDB(dbPath string) (*sql.DB, error) {
return sql.Open("sqlite3", "file:"+dbPath)
db, err := sql.Open("sqlite3", "file:"+dbPath)
if err == nil {
db.SetMaxOpenConns(1)
}

return db, err
}

//go:embed create_main_db.sql
Expand Down

0 comments on commit 5832992

Please sign in to comment.