mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-12 08:00:04 +01:00
Use driver to open SQL connection in tests
This commit is contained in:
parent
8cb676158e
commit
98a4911ff7
2 changed files with 14 additions and 4 deletions
|
|
@ -29,3 +29,13 @@ func Get(name string) (Driver, error) {
|
|||
return nil, fmt.Errorf("Unknown driver: %s", name)
|
||||
}
|
||||
}
|
||||
|
||||
// Open is a shortcut for driver.Get(u.Scheme).Open(u)
|
||||
func Open(u *url.URL) (*sql.DB, error) {
|
||||
drv, err := Get(u.Scheme)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return drv.Open(u)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue