cc-backend/test/db.go

27 lines
310 B
Go
Raw Normal View History

2022-02-11 11:04:26 +01:00
package test
import (
"fmt"
"os"
"github.com/jmoiron/sqlx"
2022-02-17 09:04:57 +01:00
_ "github.com/mattn/go-sqlite3"
2022-02-11 11:04:26 +01:00
)
func InitDB() *sqlx.DB {
bp := "./"
ebp := os.Getenv("BASEPATH")
if ebp != "" {
bp = ebp + "test/"
}
db, err := sqlx.Open("sqlite3", bp+"test.db")
if err != nil {
fmt.Println(err)
}
return db
}