1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/pkg/graphdb/conn_sqlite3.go
Bryan Matsuo 99284a24e7 FIXES #5398: pkg/graphdb build only dependent on cgo tag
Docker-DCO-1.1-Signed-off-by: Bryan Matsuo <bryan.matsuo@gmail.com> (github: bmatsuo)
2014-04-30 11:57:10 -06:00

25 lines
450 B
Go

// +build cgo
package graphdb
import (
_ "code.google.com/p/gosqlite/sqlite3" // registers sqlite
"database/sql"
"os"
)
func NewSqliteConn(root string) (*Database, error) {
initDatabase := false
if _, err := os.Stat(root); err != nil {
if os.IsNotExist(err) {
initDatabase = true
} else {
return nil, err
}
}
conn, err := sql.Open("sqlite3", root)
if err != nil {
return nil, err
}
return NewDatabase(conn, initDatabase)
}