You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
flux-feed/database/sqlx.go

30 lines
460 B
Go

package database
import (
"log"
"git.runcible.io/androiddrew/flux-feed/config"
"github.com/jmoiron/sqlx"
)
func NewSqlx(cfg config.Database) *sqlx.DB {
var dsn string
// TODO add additional database driver support
switch cfg.DatabaseDriver {
case "libsql":
if cfg.DatabaseDriver == "local" {
dsn = cfg.DatabasePath
}
default:
log.Fatal("Must choose a database driver")
}
db := sqlx.MustConnect(cfg.DatabaseDriver, dsn)
return db
}