mysql_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package mysql
  2. import (
  3. "log"
  4. "testing"
  5. )
  6. func TestMysqlSelect(t *testing.T) {
  7. m := &Mysql{
  8. Address: "192.168.3.217:4000",
  9. UserName: "root",
  10. PassWord: "=PDT49#80Z!RVv52_z",
  11. DBName: "jianyu",
  12. MaxOpenConns: 2, //用于设置最大打开的连接数,默认值为0表示不限制。
  13. MaxIdleConns: 2, //用于设置闲置的连接数。
  14. }
  15. m.Init()
  16. list := m.SelectBySql(`select * from entniche_info limit ?`, 1)
  17. log.Println("-----", list)
  18. }
  19. //
  20. func TestClickHouseSelect(t *testing.T) {
  21. m := NewInit("clickhouse", "clickhouse://jytop:pwdTopJy123@192.168.3.207:19000/information?dial_timeout=2000ms&max_execution_time=60s", 1, 1)
  22. m.SelectByBath(1, func(l *[]map[string]interface{}) bool {
  23. log.Println(l)
  24. return true
  25. }, `select * from information where createtime>=1708673243 and createtime<1708673245`)
  26. //}, `select id from information limit ?`, 1)
  27. return
  28. list := m.SelectBySql(`select id from information limit ?`, 1)
  29. c := m.CountBySql(`select count(1) as c from information`)
  30. log.Println("-----", list, c)
  31. log.Println(m.InsertBatch("wcj.test", []string{"name"}, []interface{}{"456"}))
  32. }