-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdb.go
More file actions
25 lines (21 loc) · 640 Bytes
/
db.go
File metadata and controls
25 lines (21 loc) · 640 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package main
import (
"database/sql"
"log"
_ "github.com/go-sql-driver/mysql"
)
func dbConn() (db *sql.DB) {
log.Println("Database: " + GMConfigV.DBData.Database + " (" + GMConfigV.DBData.Host +
":" + GMConfigV.DBData.Port + ")")
db, err := sql.Open(GMConfigV.DBData.Driver, GMConfigV.DBData.Username+":"+
GMConfigV.DBData.Password+"@"+GMConfigV.DBData.Protocol+
"("+GMConfigV.DBData.Host+":"+GMConfigV.DBData.Port+")/"+
GMConfigV.DBData.Database)
if err != nil {
panic(err.Error())
}
return db
}
func dbColumnQuoted(cName string) string {
return GMConfigV.DBData.ColumnQuote + cName + GMConfigV.DBData.ColumnQuote
}