Commit 107942d6 authored by Upliner's avatar Upliner

Try2

parent 61669d74
...@@ -62,22 +62,28 @@ func main() { ...@@ -62,22 +62,28 @@ func main() {
fchan := make(chan *tarantool.Future, 100000) fchan := make(chan *tarantool.Future, 100000)
go func() { go func() {
var rows []struct { var row struct {
ID uint32 `db:"id" json:"-"` ID uint32 `db:"id" json:"-"`
CatID uint32 `json:"-"` CatID uint32 `json:"-"`
URL string `json:"url"` URL string `json:"url"`
Title string `json:"name"` Title string `json:"name"`
Price float64 `json:"price"` Price json.Number `json:"price"`
Brand string `json:"vendor"` Brand string `json:"vendor"`
ImageURL float64 `json:"picture"` ImageURL string `json:"picture"`
OldPrice float64 `json:"oldprice"` OldPrice json.Number `json:"oldprice"`
CurrencyID string `json:"currencyId"` CurrencyID string `json:"currencyId"`
Description string `json:"description"` Description string `json:"description"`
} }
ms.Select(&rows,"SELECT ID,CatID,URL,Title,Price,Brand,ImageURL,OldPrice,CurrencyID,Description from goods") rows, err := ms.Query("SELECT id,CatID,URL,Title,Price,Brand,ImageURL,OldPrice,CurrencyID,Description from goods")
fmt.Println("Got",len(rows), "rows") if err != nil{
for _, row := range rows{ log.Fatal(err)
bs, _ := json.Marshal(row) }
for rows.Next(){
err := rows.Scan(&row.ID,&row.CatID,&row.URL,&row.Title,&row.Price,&row.Brand,&row.ImageURL,&row.OldPrice,&row.CurrencyID,&row.Description)
if err != nil {
log.Fatal(err)
}
bs, _ := json.Marshal(&row)
fchan <- conn.InsertAsync("retarg_goods", []interface{}{row.ID, row.CatID,string(bs)}) fchan <- conn.InsertAsync("retarg_goods", []interface{}{row.ID, row.CatID,string(bs)})
} }
close(fchan) close(fchan)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment