Пример #1
0
func Insert(db *asynql.DB) error {
	r1 := db.Exec(`INSERT INTO test_table (id, name) VALUES (?, ?)`, 1, "alice")
	r2 := db.Exec(`INSERT INTO test_table (id, name) VALUES (?, ?)`, 2, "bob")
	r3 := db.Exec(`INSERT INTO test_table (id, name) VALUES (?, ?)`, 3, "jack")
	for _, ch := range []<-chan *asynql.Result{r1, r2, r3} {
		result := <-ch
		if err := result.Err(); err != nil {
			return err
		}
	}
	return nil
}
Пример #2
0
func CreateTable(db *asynql.DB) error {
	result := db.Exec(`CREATE TABLE IF NOT EXISTS test_table (id INTEGER, name TEXT)`)
	r := <-result
	return r.Err()
}