I am trying when I run a ruby file to generate a json file, the script is working but it just display the json on the terminal, I don't know to to create a file from it, here is what I did :
require 'pg'
conn = PGconn.connect("host", 5432, '', '', "d6kabu5l22jugs", "cgcscdqtkpesow", "5fe2bc97a")
res = conn.exec('select * FROM applicants')
SELECT array_to_json(array_agg(applicants)) FROM applicants;
Thanks,