pkg/graphdb/conn_sqlite3.go
Kato Kazuyoshi d79271c0b2 SQLite is also available in FreeBSD
Docker-DCO-1.1-Signed-off-by: Kato Kazuyoshi <kato.kazuyoshi@gmail.com> (github: kzys)
2014-04-17 07:19:30 +09:00

25 lines
470 B
Go

// +build linux,amd64 freebsd,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)
}