mysql_test.go 903 B

1234567891011121314151617181920212223242526272829
  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. list := m.SelectBySql(`select id from information limit ?`, 1)
  23. c := m.CountBySql(`select count(1) as c from information`)
  24. log.Println("-----", list, c)
  25. log.Println(m.InsertBatch("wcj.test", []string{"name"}, []interface{}{"456"}))
  26. }