package logdb import ( "log" "testing" "time" _ "github.com/go-sql-driver/mysql" ) // charset: utf8mb4 // db: test_log // hosts: [192.168.6.101, 192.168.6.102, 192.168.6.103, 192.168.6.104, 192.168.6.105] // password: ag-spider-log // port: 4000 // user: spider type ADStore struct { uid string spider_id int device string platform string channel int media int area_cc string catch_account_id int section_id string response string status int error_msg string ext string priority int ts_crawl time.Time ts_update time.Time } func TestSelect(t *testing.T) { log.SetFlags(log.Llongfile) logdb := NewLogDB("logdb.yaml") logdb.Connect() t.Error(logdb) rows := logdb.Select("select uid, spider_id, device, platform, response from log_spider limit 10;") log.Println(rows) var l []ADStore for rows.Next() { ad := ADStore{} rows.Scan(&ad.uid, &ad.spider_id, &ad.device, &ad.platform, &ad.response) l = append(l, ad) } log.Println(len(l)) }