You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
422 B
Go

12 months ago
package db
import (
"database/sql"
"fmt"
11 months ago
_ "github.com/go-sql-driver/mysql"
12 months ago
)
var handle *sql.DB
func Init(username, password, protocol, address, database string) error {
var err error
handle, err = sql.Open("mysql", username+":"+password+"@"+protocol+"("+address+")/"+database)
12 months ago
if err != nil {
return fmt.Errorf("failed to open database connection: %s", err)
}
handle.SetMaxOpenConns(1000)
12 months ago
return nil
}