Move utility package 'graphdb' to pkg/graphdb
This commit is contained in:
parent
81b755db9b
commit
ced35db5c1
8 changed files with 1130 additions and 0 deletions
23
graphdb/conn_linux.go
Normal file
23
graphdb/conn_linux.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
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