[#875] reordered the busy_timeout pragma and added a fixed/capped connections pool for the nocgo sqlite driver

This commit is contained in:
Gani Georgiev
2022-11-01 20:29:07 +02:00
parent 639522b142
commit 8bb03d2e6b
4 changed files with 28 additions and 5 deletions

View File

@@ -10,7 +10,10 @@ import (
)
func connectDB(dbPath string) (*dbx.DB, error) {
pragmas := "_foreign_keys=1&_journal_mode=WAL&_synchronous=NORMAL&_busy_timeout=8000"
// note: the busy_timeout pragma must be first because
// the connection needs to be set to block on busy before WAL mode
// is set in case it hasn't been already set by another connection
pragmas := "_busy_timeout=10000&_journal_mode=WAL&_foreign_keys=1&_synchronous=NORMAL"
db, openErr := dbx.MustOpen("sqlite3", fmt.Sprintf("%s?%s", dbPath, pragmas))
if openErr != nil {