SQLite is also available in FreeBSD
Docker-DCO-1.1-Signed-off-by: Kato Kazuyoshi <kato.kazuyoshi@gmail.com> (github: kzys)
This commit is contained in:
parent
f95367f57f
commit
d79271c0b2
2 changed files with 2 additions and 2 deletions
25
graphdb/conn_sqlite3.go
Normal file
25
graphdb/conn_sqlite3.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
// +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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue