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