diff --git a/logdb_test.go b/logdb_test.go index 1e1aa37..cd26119 100644 --- a/logdb_test.go +++ b/logdb_test.go @@ -3,6 +3,7 @@ package logdb import ( "log" "testing" + "time" _ "github.com/go-sql-driver/mysql" ) @@ -14,11 +15,38 @@ import ( // port: 4000 // user: spider -func TestSelect(t *testing.T) { +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 * from log_spider limit 10;") log.Println(rows) + + var l []ADStore + for rows.Next() { + ad := ADStore{} + rows.Scan(&ad) + l = append(l, ad) + } + log.Println(len(l)) }