From 36fdaf99a84b31dda76c60d1999b70a80dd7a6aa Mon Sep 17 00:00:00 2001 From: listen <494177603@qq.com> Date: Fri, 17 Dec 2021 22:37:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BB=8E=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chain.go | 2 +- db_test.go | 31 +++++++++++++++++++++++++++---- go.mod | 1 + go.sum | 7 +++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/chain.go b/chain.go index 138c384..0dd76f9 100644 --- a/chain.go +++ b/chain.go @@ -166,7 +166,7 @@ func (this *Query) QueryStmt() error { } else { title = "*" } - sql = helper.StringJoin("select ", title) + sql = helper.StringJoin("/*slave*/ select ", title) if this.alias != "" { table = helper.StringJoin(table, " as ", this.alias) diff --git a/db_test.go b/db_test.go index 1552711..219d969 100755 --- a/db_test.go +++ b/db_test.go @@ -1,11 +1,34 @@ package dbquery import ( + "log" "testing" ) -func Test_GetTotal(t *testing.T) { - Connect() - total := GetTotal("dev_tetel_net", TABLE_CONFIG, "id") - t.Log(total) +func Test_Connet(t *testing.T) { + //go func() { + for i := 0; i < 100; i++ { + dbhost := "106.52.13.101" + dbname := "shop" + dbusername := "yueheng_read" + dbpassword := "yhmast@4&345Ms" + dbport := "13306" + err := Connect(dbhost, dbusername, dbpassword, dbname, dbport) + + if err != nil { + log.Println(err.Error()) + } + + //_,err = new(Query).Db(dbname).Table("ttl_user").Where("id > 0").Select() + + _, err = new(Query).Db(dbname).Table("ttl_news"). + Datas([]string{"title=?", "content=?"}). + Values([]interface{}{"aaaaaaaaa", "bbbbbb"}).Create() + + if err != nil { + log.Println(err.Error()) + } + } + //}() + } diff --git a/go.mod b/go.mod index be40e1b..3ab5ac9 100644 --- a/go.mod +++ b/go.mod @@ -4,5 +4,6 @@ go 1.14 require ( git.tetele.net/tgo/helper v0.1.0 + github.com/denisenkom/go-mssqldb v0.11.0 github.com/go-sql-driver/mysql v1.5.0 ) diff --git a/go.sum b/go.sum index e84aad7..adffb88 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,11 @@ git.tetele.net/tgo/helper v0.1.0 h1:ZdsBXUWX3+22ZzHTZRldBfBsQwu+CwUH8qScUvpgimE= git.tetele.net/tgo/helper v0.1.0/go.mod h1:shYQE/hvMy3fOE8JXKGxvywOXiz3M5Nw4e+u7HR8+NY= +github.com/denisenkom/go-mssqldb v0.11.0 h1:9rHa233rhdOyrz2GcP9NM+gi2psgJZ4GWDpL/7ND8HI= +github.com/denisenkom/go-mssqldb v0.11.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= +github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= +golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI= +golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=