I have a script that generates an SQL query as text e.g.
...
return "SELECT COUNT(*) FROM important_table"
which I would then like to run on a PostgreSQL database. I can do this in two lines like this:
python SQLgeneratingScript.py parameters > temp.sql
psql -f temp.sql -d my_database
But seems like I should be able to one-line it with pipes, but I don’t know how.
1 Answer