Set max open MariaDB connections

oauth2
maru 2024-04-25 16:27:24 -04:00
parent 1ea2829f63
commit 54d4d9a389
No known key found for this signature in database
GPG Key ID: 37689350E9CD0F0D
1 changed files with 4 additions and 2 deletions

View File

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