mirror of
https://github.com/p4gefau1t/trojan-go.git
synced 2024-04-21 12:21:34 +00:00
13 lines
342 B
Go
13 lines
342 B
Go
package common
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
func ConnectDatabase(driverName, username, password, ip string, port int, dbName string) (*sql.DB, error) {
|
|
path := strings.Join([]string{username, ":", password, "@tcp(", ip, ":", fmt.Sprintf("%d", port), ")/", dbName, "?charset=utf8"}, "")
|
|
return sql.Open(driverName, path)
|
|
}
|