www.fromthevalley.com.au

Extract SQL data on command line - Postgres

 

Below is how to extract data from a SQL db using the psql commands. 

 dbname = data base name in psql -l

"  Enter any sql selects including multi table selects  "

 and then you pipe the output to a csv if you use the "," option as the delimiter 

 

psql -d dbname -t -A -F"," -c "select * from users" > output.csv

 

Very handy to extract data quickly. 

HOME |  AJAX |  APACHE |  Bizphone |  CSS |  DNS |  General |  Graphics |  HTML |  Hardware |  Javascript |  Linux |  MAC |  MS SQL |  Mail |  Microsoft |  OFFICE 365 |  Perl |  Postgres |  SEO |  Social Media |  VMware |  Windows 10