fix: sql bug
This commit is contained in:
parent
4e6b70cb94
commit
98adec4b97
10
logdb.go
10
logdb.go
|
@ -100,9 +100,10 @@ func (logdb *LogDB) Connect() {
|
||||||
|
|
||||||
// ADInsert 插入数据
|
// ADInsert 插入数据
|
||||||
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) {
|
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 log_spider (uid, spider_id, device, platform, channel, media, area_cc, catch_account_id, section_id, response, error_msg, status, priority, ts_crawl) value(?, ?, ?, ?, ?, ?, ?, ?, ?, ? , ? ,?, ?, ?)", uid, spider_id, device, platform, channel, media, area_cc, catch_account_id, section_id, response, "", status, priority, ts_crawl)
|
_, err := logdb.driver.Exec("insert into log_spider (uid, spider_id, device, platform, channel, media, area_cc, catch_account_id, section_id, response, error_msg, status, priority, ts_crawl) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ? , ? ,?, ?, ?)", uid, spider_id, device, platform, channel, media, area_cc, catch_account_id, section_id, response, "", status, priority, ts_crawl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
log.Printf("for save ad sql: insert into log_spider (uid, spider_id, device, platform, channel, media, area_cc, catch_account_id, section_id, response, error_msg, status, priority, ts_crawl) values(%s, %s, %s, %s, %d, %d, %s, %d, %s, %s, %s, %d, %d, %s)\n", uid, spider_id, device, platform, channel, media, area_cc, catch_account_id, section_id, response, "", status, priority, ts_crawl.Format("2006-01-02 15:04:05"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,11 +120,13 @@ func (logdb *LogDB) ADParserSelect(spider_id int) []ADResonse {
|
||||||
_, err := logdb.driver.Exec("update log_spider set status = ? where spider_id = ? and status = 0 limit 100", pid, spider_id)
|
_, err := logdb.driver.Exec("update log_spider set status = ? where spider_id = ? and status = 0 limit 100", pid, spider_id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := logdb.driver.Query("select uid, response from log_spider where spider_id = ? and status = ?", spider_id, pid)
|
rows, err := logdb.driver.Query("select uid, response from log_spider where spider_id = ? and status = ?", spider_id, pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var adresponse []ADResonse
|
var adresponse []ADResonse
|
||||||
|
@ -144,7 +147,7 @@ func (logdb *LogDB) ADCheckError(spider_id int) {
|
||||||
logdb.nextCheck = now.Unix() + logdb.checkLimit
|
logdb.nextCheck = now.Unix() + logdb.checkLimit
|
||||||
|
|
||||||
tsUpdate := now.Add(-time.Minute * 5)
|
tsUpdate := now.Add(-time.Minute * 5)
|
||||||
_, err := logdb.driver.Exec("update status = 0, error_msg = errror_msg || 'Parser Timeout ' where status > 2000 and spider_id = ? and ts_update <= ?", spider_id, tsUpdate)
|
_, err := logdb.driver.Exec("update log_spider set status = 0, error_msg = CONCAT(error_msg, 'Parser Timeout ') where status > 2000 and spider_id = ? and ts_update <= ?", spider_id, tsUpdate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
|
@ -156,13 +159,14 @@ func (logdb *LogDB) Select(query string, args ...interface{}) *sql.Rows {
|
||||||
Rows, err := logdb.driver.Query(query, args...)
|
Rows, err := logdb.driver.Query(query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return Rows
|
return Rows
|
||||||
}
|
}
|
||||||
|
|
||||||
// ADError 广告错误后更新
|
// ADError 广告错误后更新
|
||||||
func (logdb *LogDB) ADError(uid, error_msg string) {
|
func (logdb *LogDB) ADError(uid, error_msg string) {
|
||||||
_, err := logdb.driver.Exec("update log_spider set status = 1000, error_msg=? where uid =?;", logdb.DB, error_msg, uid)
|
_, err := logdb.driver.Exec("update log_spider set status = 1000, error_msg=? where uid =?;", error_msg, uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user