mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-11 23:50:04 +01:00
21 lines
401 B
Go
21 lines
401 B
Go
package shared
|
|
|
|
import (
|
|
"database/sql"
|
|
"net/url"
|
|
)
|
|
|
|
// DatabaseName returns the database name from a URL
|
|
func DatabaseName(u *url.URL) string {
|
|
name := u.Path
|
|
if len(name) > 0 && name[:1] == "/" {
|
|
name = name[1:len(name)]
|
|
}
|
|
|
|
return name
|
|
}
|
|
|
|
// Transaction can represent a database or open transaction
|
|
type Transaction interface {
|
|
Exec(query string, args ...interface{}) (sql.Result, error)
|
|
}
|