Skip to content

Commit

Permalink
Update mysql connection string & add missing port config option
Browse files Browse the repository at this point in the history
  • Loading branch information
CraigChilds94 committed Aug 8, 2018
1 parent 3a962bf commit 32fdd30
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion msq/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package msq
import (
"errors"
"fmt"
"strconv"

"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
Expand All @@ -12,6 +13,7 @@ import (
type ConnectionConfig struct {
Type string
Host string
Port int
Username string
Password string
Database string
Expand Down Expand Up @@ -73,10 +75,11 @@ func (c *Connection) getConnectionString() string {

if dbType == "mysql" {
return fmt.Sprintf(
"%s:%s@%s/%s?charset=%s&parseTime=True&loc=%s",
"%s:%s@tcp(%s:%s)/%s?charset=%s&parseTime=True&loc=%s",
c.Config.Username,
c.Config.Password,
c.Config.Host,
strconv.Itoa(c.Config.Port),
c.Config.Database,
c.Config.Charset,
c.Config.Locale,
Expand Down

0 comments on commit 32fdd30

Please sign in to comment.