What is the easiest way to save PL/pgSQL output from a PostgreSQL database to a CSV file?
I\'m using PostgreSQL 8.4 with pgAdmin III and PSQL plugin where I run que
import json cursor = conn.cursor() qry = """ SELECT details FROM test_csvfile """ cursor.execute(qry) rows = cursor.fetchall() value = json.dumps(rows) with open("/home/asha/Desktop/Income_output.json","w+") as f: f.write(value) print 'Saved to File Successfully'