添加mysql的调试代码
This commit is contained in:
@@ -25,7 +25,12 @@ func NewGorm(opts ...Option) *gorm.DB {
|
|||||||
panic("mysql is not supported")
|
panic("mysql is not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
dsn := fmt.Sprintf("%s:%s@tcp(%s:%v)/%s?charset=utf8mb4&parseTime=True&loc=Local", defaultOpts.Mysql.User, defaultOpts.Mysql.Password, defaultOpts.Mysql.Host, defaultOpts.Mysql.Port, defaultOpts.Mysql.Database)
|
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True&loc=Local",
|
||||||
|
defaultOpts.Mysql.User,
|
||||||
|
defaultOpts.Mysql.Password,
|
||||||
|
defaultOpts.Mysql.Host,
|
||||||
|
defaultOpts.Mysql.Port,
|
||||||
|
defaultOpts.Mysql.Database)
|
||||||
dialector = mysql.Open(dsn)
|
dialector = mysql.Open(dsn)
|
||||||
|
|
||||||
} else if defaultOpts.Db == "sqlite" {
|
} else if defaultOpts.Db == "sqlite" {
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package gormx_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"code.yun.ink/pkg/gormx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGormx(t *testing.T) {
|
||||||
|
db := gormx.NewGorm(gormx.SetMysql(
|
||||||
|
"root",
|
||||||
|
"Huang@Yun.Ink123",
|
||||||
|
"127.0.0.1",
|
||||||
|
"xiaoxin-plus",
|
||||||
|
3306,
|
||||||
|
))
|
||||||
|
db.Get("")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user