I'm trying to write a script in R to export a query from a Postgresql database to a csv file.
If I do this from cmd it works fine :
psql -U postgres
\copy (select * from clickthru.train limit 10) to 'c:\\me\\psql_test.csv' with csv header;
However when I try this in R it looks like it executes (no errors) but no file is generated:
system('psql -U postgres COPY (select * from clickthru.train limit 10;) TO "C:\\me\\psql_test.csv" with CSV')
Any suggestions?
queryResult <- however you're running your querythen usewrite.csv(queryResult, 'c:\\me\\psql_test.csv'&