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. 

HOMEAJAXAPACHEBizphoneCSSDNSGeneralGraphicsHTMLHardwareJavascriptLinuxMACMS SQLMailMicrosoftOFFICE 365PerlPostgresSEOSocial MediaVMwareWindows 10