MCPcopy
hub / github.com/benbjohnson/litestream / MustOpenSQLDB

Function MustOpenSQLDB

internal/testingutil/testingutil.go:207–218  ·  view source on GitHub ↗

MustOpenSQLDB returns a database/sql DB.

(tb testing.TB, path string)

Source from the content-addressed store, hash-verified

205
206// MustOpenSQLDB returns a database/sql DB.
207func MustOpenSQLDB(tb testing.TB, path string) *sql.DB {
208 tb.Helper()
209 d, err := sql.Open("sqlite", path)
210 if err != nil {
211 tb.Fatal(err)
212 } else if _, err := d.ExecContext(context.Background(), `PRAGMA journal_mode = wal;`); err != nil {
213 tb.Fatal(err)
214 } else if _, err := d.ExecContext(context.Background(), `PRAGMA busy_timeout = 5000;`); err != nil {
215 tb.Fatal(err)
216 }
217 return d
218}
219
220// MustCloseSQLDB closes a database/sql DB.
221func MustCloseSQLDB(tb testing.TB, d *sql.DB) {

Calls 1

OpenMethod · 0.45