36 lines
727 B
Go
36 lines
727 B
Go
package lib
|
|
|
|
import (
|
|
"fmt"
|
|
"kefu/tools"
|
|
"log"
|
|
"testing"
|
|
)
|
|
|
|
func TestImportSqlTool_QuerySql(t *testing.T) {
|
|
db := &DBTool{
|
|
Username: "BT_DB_USERNAME",
|
|
Password: "BT_DB_PASSWORD",
|
|
Server: "127.0.0.1",
|
|
Port: "3306",
|
|
Database: "BT_DB_NAME",
|
|
}
|
|
res, err := db.QuerySql("select * from user")
|
|
log.Println(res, err)
|
|
}
|
|
func TestUpdateUserUuid(t *testing.T) {
|
|
db := &DBTool{
|
|
Username: "go_fly_pro",
|
|
Password: "go_fly_pro",
|
|
Server: "127.0.0.1",
|
|
Port: "3306",
|
|
Database: "go_fly_pro",
|
|
}
|
|
res, _ := db.QuerySql("select * from user")
|
|
for _, row := range res {
|
|
name := row["name"]
|
|
sql := fmt.Sprintf("update user set uuid = '%s' where name = '%s'", tools.Uuid2(), name)
|
|
db.ExecuteSql(sql)
|
|
}
|
|
}
|