diff --git a/utils/misc.go b/utils/misc.go index 661daf6..69232c2 100644 --- a/utils/misc.go +++ b/utils/misc.go @@ -546,8 +546,15 @@ func TransSQLAchemyURL(pySQLSrc string) (dialect, ret string, err error) { return dialect, pySQLSrc, nil } - r := regexp.MustCompile(`[/@:]+`) - strs := r.Split(pySQLSrc, -1) + lastAtIndex := strings.LastIndex(pySQLSrc, "@") + firstPart := pySQLSrc[:lastAtIndex] + secondPart := pySQLSrc[lastAtIndex+1:] + + r := regexp.MustCompile(`[/:]+`) + firstPartArr := r.Split(firstPart, -1) + secondPartArr := r.Split(secondPart, -1) + + strs := append(firstPartArr, secondPartArr...) if len(strs) != 6 { err = fmt.Errorf("Incorrect mysql connection url: %s", pySQLSrc) return diff --git a/utils/misc_test.go b/utils/misc_test.go index 2b6ed1e..c1d6744 100644 --- a/utils/misc_test.go +++ b/utils/misc_test.go @@ -669,6 +669,11 @@ func TestTransSQLAchemyURL(t *testing.T) { args: args{"root:root@127.0.0.1:3306/mclouds?charset=utf8"}, wantRet: "root:root@127.0.0.1:3306/mclouds?charset=utf8", wantErr: false, + }, { + name: "supported at", + args: args{"mysql+pymysql://root:5bTcx^@Peh4nj3H7@127.0.0.1:3306/mclouds?charset=utf8"}, + wantRet: "root:5bTcx^@Peh4nj3H7@tcp(127.0.0.1:3306)/mclouds?charset=utf8&parseTime=True", + wantErr: false, }, } for _, tt := range tests {