PostgreSQL – PgSql – Write output to CSV Excel

Sometimes it doesn’t have to be that difficult :

With the following statement you are able to import your (postgres) sql statements (file.sql) and write the corresponding output to a csv file (output_file.csv)

The name of the psql database and the psql user is ‘ dbname ‘ and all the columns are divided by ‘ | ‘

psql -F\| -A -f file.sql -o output_file.csv -h localhost -U dbname

Comments

One Response to “PostgreSQL – PgSql – Write output to CSV Excel”

  1. Gregor on January 21st, 2010 3:51 pm

    Awesome! That was a real time saver.

Leave a Reply