How hard would it be to capture the output of postgres blocks? My current workflow is to use a psql block to design my query, then I use a normal script block to invoke ‘psql -t’ with some json_agg and jq to get my response into a script variable.
I’ll share an example once I’m back at my desk.
Just wondering if it’s on the road map, or possible at all, really
EDIT: here is what I currently do in a script block:
nix shell nixpkgs#postgresql -c psql -t {{var.CONNECTION_STRING | trim}}/mydb -c \
"SELECT json_agg(row_to_json(t)) FROM
(SELECT foo FROM table WHERE bar = '{{var.XXX}}') t" \
| jq .[0].foo