|
|
|
@ -10,12 +10,14 @@ import (
|
|
|
|
|
var handle *sql.DB
|
|
|
|
|
|
|
|
|
|
func Init(username, password, protocol, address, database string) error {
|
|
|
|
|
db, err := sql.Open("mysql", username+":"+password+"@"+protocol+"("+address+")/"+database)
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
handle, err = sql.Open("mysql", username+":"+password+"@"+protocol+"("+address+")/"+database)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return fmt.Errorf("failed to open database connection: %s", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handle = db
|
|
|
|
|
handle.SetMaxOpenConns(1000)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|