mirror of https://github.com/jackc/pgx.git
parent
ef470b1e30
commit
fdeb2412ec
|
@ -2,6 +2,7 @@ package pgx_test
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/JackC/pgx"
|
||||
"strings"
|
||||
"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) {
|
||||
conn := getSharedConnection()
|
||||
|
||||
|
|
Loading…
Reference in New Issue