Skip to content
Permalink
Browse files

Merge pull request #104 from joseluis2g/master

Mysql fix
  • Loading branch information...
Raggaer committed Mar 22, 2019
2 parents f6cb036 + 23e665d commit bb1722f483182a8af5c14cf0dcadf1fc41dcb6ae
Showing with 14 additions and 6 deletions.
  1. +6 −1 app/app.go
  2. +4 −2 app/database/database.go
  3. +4 −3 install.go
@@ -487,7 +487,12 @@ func connectDatabase() {
var err error

// Connect to the MySQL database
if database.DB, err = database.Open(lua.Config.GetGlobal("mysqlUser").String(), lua.Config.GetGlobal("mysqlPass").String(), lua.Config.GetGlobal("mysqlDatabase").String(), ""); err != nil {
if database.DB, err = database.Open(lua.Config.GetGlobal("mysqlUser").String(),
lua.Config.GetGlobal("mysqlPass").String(),
lua.Config.GetGlobal("mysqlHost").String(),
lua.Config.GetGlobal("mysqlPort").String(),
lua.Config.GetGlobal("mysqlDatabase").String(),
""); err != nil {
util.Logger.Logger.Fatalf("Cannot connect to MySQL database: %v", err)
}
}
@@ -12,12 +12,14 @@ import (
var DB *sqlx.DB

// Open creates a new connection to a MySQL database with the given credentials
func Open(username, password, db, params string) (*sqlx.DB, error) {
func Open(username, password, host, port, db, params string) (*sqlx.DB, error) {
// Connect to the given database
databaseHandle, err := sqlx.Connect("mysql", fmt.Sprintf(
"%v:%v@/%v?charset=utf8&parseTime=True&loc=Local"+params,
"%v:%v@(%v:%v)/%v?charset=utf8&parseTime=True&loc=Local"+params,
username,
password,
host,
port,
db,
))

@@ -544,9 +544,10 @@ func installApplication(location string) error {
}

// Connect to database
conn, err := database.Open(
lua.Config.GetGlobal("mysqlUser").String(),
lua.Config.GetGlobal("mysqlPass").String(),
conn, err := database.Open(lua.Config.GetGlobal("mysqlUser").String(),
lua.Config.GetGlobal("mysqlPass").String(),
lua.Config.GetGlobal("mysqlHost").String(),
lua.Config.GetGlobal("mysqlPort").String(),
lua.Config.GetGlobal("mysqlDatabase").String(),
"&multiStatements=true",
)

0 comments on commit bb1722f

Please sign in to comment.
You can’t perform that action at this time.