Feature request: interleave SQL with output

I teach an SQL class at a community college. We use PostgreSQL as the database for the learning. The students have always used the Unix command line to access the database. For me, it's an excellent pedagogical tool.

* Everyone can use it, no matter if they have Mac, Windows, or Linux. All they need is an SSH app.
* There's no hand-holding. No query builders. No table builders. The students must write their own SQL.
* Easy to import data using the \copy command.
* Easy to copy-and-paste the output for hard copy. I have the students do a dozen or so queries per assignment. They turn in a printout showing the query they typed followed by the first few lines of output to show that it worked. In a terminal window, they just copy-and-paste into a text editor such as Notepad or TextEdit.

It's also free.

The primary problems using psql are:
* Learning curve of Unix (although I teach them what they need to know).
* Queries producing wide output are hard to view on screen.

I've looked at several other GUI frontends for PostgreSQL such as PgAdmin and OpenOffice. My aim is to find one that meets the pedagogical goals listed above. None do. But pgEdit comes very close. I will recommend it to my students next semester.

My feature request:
Would it be possible to have an option to interleave the SQL queries with the output? I'd love for the students to be able to type in their queries in the top part of the window, then hit a key (such as Cmd-B) to execute them all. In the output below, show the query that was executed followed by its output, then the next query and output, and so forth. The query itself could be commented out or otherwise distinguished in the output.

What do you think?

RE: interleave SQL with output

Since the editor input is processed by psql, all you need to do is tell psql to echo the query before printing the output. This can be accomplished with a psql command:

\set ECHO queries