mirror of
https://github.com/jackc/pgx.git
synced 2025-04-29 07:21:43 +00:00
parent
ef470b1e30
commit
fdeb2412ec
@ -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()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user