SQL get data out of BEGIN; ...; END; block in python
- by Claudiu
I want to run many select queries at once by putting them between BEGIN; END;. I tried the following:
cur = connection.cursor()
cur.execute("""
BEGIN;
SELECT ...;
END;""")
res = cur.fetchall()
However, I get the error:
psycopg2.ProgrammingError: no results to fetch
How can I actually get data this way?
Likewise, if I just have many selects in a row, I only get data back from the latest one. Is there a way to get data out of all of them?