micro-wrapper-sql/driver.go
Vasiliy Tolstov 3f1068e708 update workflows
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-27 18:49:33 +03:00

26 lines
602 B
Go

package wrapper
import (
"database/sql/driver"
)
// wrapperDriver defines a wrapper for driver.Driver
type wrapperDriver struct {
driver driver.Driver
opts Options
}
// NewWrapper creates and returns a new SQL driver with passed capabilities
func NewWrapper(d driver.Driver, opts ...Option) driver.Driver {
return &wrapperDriver{driver: d, opts: NewOptions(opts...)}
}
// Open implements driver.Driver Open
func (w *wrapperDriver) Open(name string) (driver.Conn, error) {
c, err := w.driver.Open(name)
if err != nil {
return nil, err
}
return &wrapperConn{conn: c, opts: w.opts}, nil
}