MarketingSystemDataTool/server/internal/db/mysql.go

18 lines
345 B
Go

package db
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func ConnectMySQL(dsn string) (*sql.DB, error) {
if dsn == "" {
return sql.Open("mysql", "invalid:invalid@tcp(localhost:3306)/invalid")
}
db, err := sql.Open("mysql", dsn)
if err != nil {
return nil, err
}
return db, nil
}