github.com/jgbaldwinbrown/perf@v0.1.1/storage/db/sqlite3/sqlite3.go (about) 1 // Copyright 2017 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build cgo 6 // +build cgo 7 8 // Package sqlite3 provides the sqlite3 driver for 9 // x/perf/storage/db. It must be imported instead of go-sqlite3 to 10 // ensure foreign keys are properly honored. 11 package sqlite3 12 13 import ( 14 "database/sql" 15 16 sqlite3 "github.com/mattn/go-sqlite3" 17 "golang.org/x/perf/storage/db" 18 ) 19 20 func init() { 21 db.RegisterOpenHook("sqlite3", func(db *sql.DB) error { 22 db.Driver().(*sqlite3.SQLiteDriver).ConnectHook = func(c *sqlite3.SQLiteConn) error { 23 _, err := c.Exec("PRAGMA foreign_keys = ON;", nil) 24 return err 25 } 26 return nil 27 }) 28 }