Skip to content

How can I get the results of 2 select statements when running an sql file #1771

Answered by jackc
jbarisan asked this question in Q&A
Discussion options

You must be logged in to vote

You will need to drop down to the pgconn layer to do that. Use https://pkg.go.dev/github.com/jackc/pgx/v5#Conn.PgConn to get access to that. Then execute your query with https://pkg.go.dev/github.com/jackc/pgx/[email protected]/pgconn#PgConn.Exec. It will return a MultiResultReader which you can use to iterate through the results. https://pkg.go.dev/github.com/jackc/pgx/v5#RowsFromResultReader can also be used to handle type conversion if you need more than the string format of the results.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jbarisan
Comment options

Answer selected by jbarisan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants