Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgx Module: Add support for handling query result sets with a passed func #295

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nickman
Copy link

@nickman nickman commented Nov 29, 2024

Enhancement to the pgx module where query returned rows can be handled by a passed func rather than returning the whole result set.

e.g.

p := pgx.connect("postgres://user:[email protected]:5432/db")
rcnt := p.queryFunc("SELECT * FROM generate_series($1::integer, $2::integer)", func(row) {
    return true
}, 1, 100000)
printf("rows returned: %d\n", rcnt)
p.close()

Some benefits when:

  • Processing large datasets, as it allows for processing each row as it is received from the database, rather than waiting for the entire result set to be returned.
  • When result set processing should be stopped based on a condition.

Updated docs and provided unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant