Eric Guo's blog.cloud-mes.com

in HTML5, JavaScript, Ruby & Rails, Python, and Cloud MES!

Export the CSV Directly in Postgresql Psql

Permalink

Export the data from SQL

psql -d postgres
\copy (SELECT vote_options.title, vote_options.vote_index, vote_options.user_votes_count, (DENSE_RANK() OVER(ORDER BY user_votes_count DESC ) ) as rank FROM "vote_options" WHERE "vote_options"."vote_id" = 1 ORDER BY "rank") to 'vote_rank.csv' with csv

Comments