if sql operate error, report the log

This commit is contained in:
huangsimin 2018-12-18 15:04:19 +08:00
parent b74fe37eb5
commit 5c60cd7252

View File

@ -95,7 +95,7 @@ func (logdb *LogDB) Connect() {
func (logdb *LogDB) ADInsert(uid, device, platform, area_cc, section_id, response string, spider_id, channel, media, catch_account_id, status, priority int, ts_crawl time.Time) {
_, err := logdb.driver.Exec("insert into "+logdb.DB+"(uid, spider_id, device, platform, channel, media, area_cc, catch_account_id, section_id, response, status, priority, ts_crawl) value(?, ?, ?, ?, ?, ?, ?, ?, ?, ? , ? ,? ,? ,?)", uid, spider_id, device, platform, channel, media, area_cc, catch_account_id, section_id, response, status, priority, ts_crawl)
if err != nil {
panic(err)
log.Println(err)
}
}
@ -103,7 +103,7 @@ func (logdb *LogDB) ADInsert(uid, device, platform, area_cc, section_id, respons
func (logdb *LogDB) Select(query string, args ...interface{}) *sql.Rows {
Rows, err := logdb.driver.Query(query, args...)
if err != nil {
panic(err)
log.Println(err)
}
return Rows
}
@ -112,6 +112,6 @@ func (logdb *LogDB) Select(query string, args ...interface{}) *sql.Rows {
func (logdb *LogDB) ADError(uid, error_msg string) {
_, err := logdb.driver.Exec("update "+logdb.DB+" set status = status + 1000, error_msg=? where uid =?;", error_msg, uid)
if err != nil {
panic(err)
log.Println(err)
}
}