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
Raw Normal View History

2022-05-10 19:44:41 +05:00
package main
import (
2022-05-14 14:17:52 +05:00
"database/sql"
"io"
2022-05-10 19:44:41 +05:00
_ "github.com/denisenkom/go-mssqldb"
2022-05-14 14:17:52 +05:00
mssql "github.com/denisenkom/go-mssqldb"
2022-05-10 19:44:41 +05:00
_ "github.com/jackc/pgx/stdlib"
2022-05-14 14:17:52 +05:00
"github.com/nxshock/logwriter"
2022-05-10 19:44:41 +05:00
_ "github.com/sijms/go-ora/v2"
)
2022-05-14 14:17:52 +05:00
// 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
}