// Package database provides utility functions for connecting to and // interacting with various database backends. // // This package supports multiple database drivers including: // - sqlite3 // - others coming soon...maybe package database import ( "log" "git.runcible.io/androiddrew/flux-feed/config" "github.com/jmoiron/sqlx" ) // NewSqlx configures a new sqlx.DB from application config func NewSqlx(cfg config.Database) *sqlx.DB { var dsn string // TODO add additional database driver support switch cfg.DatabaseDriver { case "sqlite3": dsn = cfg.DatabaseDSN default: log.Fatal("Must choose a database driver") } db := sqlx.MustConnect(cfg.DatabaseDriver, dsn) return db }