mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-12 16:10:03 +01:00
Initial commit
This commit is contained in:
commit
9cfc758ca1
14 changed files with 697 additions and 0 deletions
21
driver/shared/shared.go
Normal file
21
driver/shared/shared.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue