~james/core

core/sqlite/sqlite.go -rw-r--r-- 426 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 14 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package sqlite

import (
	"database/sql"
	"strings"

	_ "github.com/mattn/go-sqlite3"
)

// https://github.com/mattn/go-sqlite3#connection-string
var dsnOpts = []string{
	"_foreign_keys=1",
	"_journal_mode=WAL",
	"_synchronous=NORMAL",
	"_auto_vacuum=incremental",
	"_busy_timeout=5000",
	"_txlock=immediate",
}

func Open(dbPath string) (*sql.DB, error) {
	return sql.Open("sqlite3", dbPath+"?"+strings.Join(dsnOpts, "&"))
}