Browse Source

尝试从读

master v0.5.6
listen 2 years ago
parent
commit
36fdaf99a8
4 changed files with 36 additions and 5 deletions
  1. +1
    -1
      chain.go
  2. +27
    -4
      db_test.go
  3. +1
    -0
      go.mod
  4. +7
    -0
      go.sum

+ 1
- 1
chain.go View File

@ -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)


+ 27
- 4
db_test.go View File

@ -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())
}
}
//}()
}

+ 1
- 0
go.mod View File

@ -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
)

+ 7
- 0
go.sum View File

@ -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=

Loading…
Cancel
Save