1
This commit is contained in:
parent
b934782a38
commit
d731e1cb0a
29
dbpool.go
29
dbpool.go
@ -110,6 +110,35 @@ func (this *dbPool) SyncSelectCustomQuery(dataSource string, sql string, cb Quer
|
||||
}
|
||||
}
|
||||
|
||||
func (this *dbPool) SyncBatchLoadFullTable(dataSource string, sqlTpl string,
|
||||
cb func(*DataSet), errCb func(error)) {
|
||||
var lastIdx int64
|
||||
var done = false
|
||||
for !done {
|
||||
this.SyncSelectCustomQuery(
|
||||
dataSource,
|
||||
fmt.Sprintf(sqlTpl, lastIdx),
|
||||
func (err error, ds *DataSet) {
|
||||
if err != nil {
|
||||
errCb(err)
|
||||
return
|
||||
}
|
||||
for ds.Next() {
|
||||
idx := q5.ToInt64(ds.GetByName("idx"))
|
||||
cb(ds)
|
||||
if idx > lastIdx {
|
||||
lastIdx = idx
|
||||
} else {
|
||||
panic(fmt.Sprintf("SyncBatchLoadFullTable idx error:%s %s", idx, lastIdx))
|
||||
}
|
||||
}
|
||||
if ds.NumOfReaded() <= 0 {
|
||||
done = true
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (this *dbPool) SelectLike(
|
||||
dataSource string,
|
||||
tblName string,
|
||||
|
Loading…
x
Reference in New Issue
Block a user