Add example for SelectFunc

fixes #6
This commit is contained in:
Jack Christensen 2013-07-18 08:39:37 -05:00
parent ef470b1e30
commit fdeb2412ec

View File

@ -2,6 +2,7 @@ package pgx_test
import ( import (
"bytes" "bytes"
"fmt"
"github.com/JackC/pgx" "github.com/JackC/pgx"
"strings" "strings"
"testing" "testing"
@ -202,6 +203,26 @@ func TestSelectFuncFailure(t *testing.T) {
} }
} }
func Example_connectionSelectFunc() {
conn := getSharedConnection()
onDataRow := func(r *pgx.DataRowReader) error {
fmt.Println(r.ReadValue())
return nil
}
err := conn.SelectFunc("select generate_series(1,$1)", onDataRow, 5)
if err != nil {
fmt.Println(err)
}
// Output:
// 1
// 2
// 3
// 4
// 5
}
func TestSelectRows(t *testing.T) { func TestSelectRows(t *testing.T) {
conn := getSharedConnection() conn := getSharedConnection()