我一直在玩这个用于 Go 的 SQLite 库,在做一些压力测试时,遇到了一些奇怪的错误。我正在尝试运行此代码:package mainimport "code.google.com/p/go-sqlite/go1/sqlite3"import "fmt"import "sync"func main() { var wg sync.WaitGroup wg.Add(100) for i := 0; i < 100; i++ { query(&wg, i) } wg.Wait()}func query(wg *sync.WaitGroup, id int) { defer wg.Done() c, _ := sqlite3.Open("sqlite.db") for i := 0; i < 100; i++{ args := sqlite3.NamedArgs{"$bval": "demo"} sql := "SELECT rowid, * FROM x WHERE b = $bval" row := make(sqlite3.RowMap) for s, err := c.Query(sql, args); err == nil; err = s.Next() { var rowid int64 s.Scan(&rowid, row) // Assigns 1st column to rowid, the rest to row fmt.Println(rowid, row) // Prints "1 map[a:1 b:demo c:<nil>]" } } c.Close() fmt.Println("Worker ", id, " is done")}
1 回答
- 1 回答
- 0 关注
- 398 浏览
添加回答
举报
0/150
提交
取消