func (c *Connection) Close() error {
	err := c.DB.Close()
	if err != nil {
		c.logger.Log().Errorf("error closing connection to %s: %v", c.params.DBName, err)
	}
	return err
}
Close terminates the database server connection.
package storage
import (
	"fmt"
	"time"
	"github.com/lbryio/lbrytv/internal/metrics"
	"github.com/lbryio/lbrytv/internal/monitor"
	_ "github.com/jinzhu/gorm/dialects/postgres"  
	"github.com/jmoiron/sqlx"
	"github.com/sirupsen/logrus"
	"github.com/volatiletech/sqlboiler/boil"
)
type Handler interface {
	MigrateUp()
	MigrateDown()
	Connect()
}
type Connection struct {
	DB      *sqlx.DB
	dialect string
	params  ConnParams
	logger  monitor.ModuleLogger
}
type ConnParams struct {
	Connection     string
	DBName         string
	Options        string
	MigrationsPath string
}
var Conn *Connection
func MakeDSN(params ConnParams) string {
	return fmt.Sprintf(
		"%v/%v?%v",
		params.Connection,
		params.DBName,
		params.Options,
	)
}
func InitConn(params ConnParams) *Connection {
	c := &Connection{
		dialect: "postgres",
		logger:  monitor.NewModuleLogger("storage"),
		params:  params,
	}
	return c
}
func (c *Connection) Connect() error {
	dsn := MakeDSN(c.params)
	c.logger.WithFields(logrus.Fields{"dsn": dsn}).Info("connecting to the DB")
	var err error
	db, err := sqlx.Connect(c.dialect, dsn)
	if err != nil {
		c.logger.WithFields(logrus.Fields{"dsn": dsn}).Info("DB connection failed")
		return err
	}
	c.DB = db
	return nil
}
func (c *Connection) SetDefaultConnection() {
	boil.SetDB(c.DB)
	Conn = c
}