hanayo/vendor/github.com/thehowl/qsql/new.go
2019-02-23 13:29:15 +00:00

18 lines
341 B
Go

package qsql
import "database/sql"
// New creates a new *DB having an *sql.DB.
func New(db *sql.DB) *DB {
if db == nil {
return nil
}
return &DB{*db}
}
// Open behaves the same as sql.Open, but creates an *qsql.DB instead.
func Open(driverName, dsn string) (*DB, error) {
db, err := sql.Open(driverName, dsn)
return New(db), err
}