1
0
mirror of https://github.com/nxshock/gron.git synced 2024-11-27 03:41:00 +05:00
gron/db.go

31 lines
748 B
Go

package main
import (
"database/sql"
"io"
_ "github.com/denisenkom/go-mssqldb"
mssql "github.com/denisenkom/go-mssqldb"
_ "github.com/jackc/pgx/stdlib"
"github.com/nxshock/logwriter"
_ "github.com/sijms/go-ora/v2"
)
// openMsSqlDb copies MS SQL Driver because logger can be assigned only for driver
func openMsSqlDb(dataSourceName string, logger io.Writer) (*sql.DB, error) {
// Init logger
lw := logwriter.New(logger)
defer lw.Close()
lw.TimeFormat = config.TimeFormat
driverInstance := &mssql.Driver{} // TODO: check hidden processQueryText field
driverInstance.SetLogger(&LogWriter{lw})
connector, err := driverInstance.OpenConnector(dataSourceName)
if err != nil {
return nil, err
}
return sql.OpenDB(connector), nil
}