MCPcopy Create free account
hub / github.com/code-scan/Goal / login

Function login

Glogin/sql.go:12–27  ·  view source on GitHub ↗
(host, port, username, password, type_ string)

Source from the content-addressed store, hash-verified

10)
11
12func login(host, port, username, password, type_ string) (*gorm.DB, bool) {
13 var connStr string
14 switch type_ {
15 case "mysql":
16 connStr = fmt.Sprintf("%s:%s@tcp(%s:%s)/?timeout=%ds", username, password, host, port, 10)
17 case "postgres":
18 connStr = fmt.Sprintf("host=%s port=%s user=%s dbname=test sslmode=disable password=%s timeout=%ds", host, port, username, password, 10)
19 case "mssql":
20 connStr = fmt.Sprintf("server=%s;user id=%s;password=%s;port=%s;database=test;timeout=%ds", host, username, password, port, 10)
21 }
22 db, err := gorm.Open(type_, connStr)
23 if err != nil {
24 return nil, false
25 }
26 return db, true
27}
28func SqlLogin(host, port, username, password, type_ string) bool {
29 db, isLogin := login(host, port, username, password, type_)
30 if isLogin {

Callers 2

SqlLoginFunction · 0.85
SqlQueryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected