bbgo_origin/pkg/cmd/cmdutil/db.go
2020-10-21 15:58:58 +08:00

15 lines
269 B
Go

package cmdutil
import (
"fmt"
"github.com/jmoiron/sqlx"
"github.com/spf13/viper"
)
func ConnectMySQL() (*sqlx.DB, error) {
mysqlURL := viper.GetString("mysql-url")
mysqlURL = fmt.Sprintf("%s?parseTime=true", mysqlURL)
return sqlx.Connect("mysql", mysqlURL)
}