Skip to content

Single line input for psql copy command

I have the following problem:

A database server and another client machine. I have to execute several \copy commands in psql on the client machine to retrieve data and store the output in CSV files. The PostgreSQL COPY command is not an option because it stores the results on the database server, not the client machine. All \copy commands are executed from several files containing SQL commands, which are concated together by a makefile and feeded into psql. So far so good.

My SELECT commands used in the \copy are a bit more complicated and \copy requires to have the entire command on a single line. That can be done in two ways:

- Write the entire command in a single line. But that's hard to debug :-(

- Write the command as i like it and remove the linebreaks before feeding the command into psql.

Continue reading "Single line input for psql copy command"
  • Twitter
  • Bookmark Single line input for psql copy command at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Single line input for psql copy command
  • Bloglines Single line input for psql copy command
  • Technorati Single line input for psql copy command
  • Fark this: Single line input for psql copy command
  • Bookmark Single line input for psql copy command at YahooMyWeb
  • Bookmark Single line input for psql copy command at Furl.net
  • Bookmark Single line input for psql copy command at reddit.com
  • Bookmark Single line input for psql copy command at blinklist.com
  • Bookmark Single line input for psql copy command at Spurl.net
  • Bookmark Single line input for psql copy command at Simpy.com
  • Bookmark Single line input for psql copy command at blogmarks
  • Bookmark Single line input for psql copy command with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

stop psql on first error

Because i always forget how to stop psql on the first error:


\set ON_ERROR_STOP


You can include this at the top of your script/file, psql will stop right after the first error and will not try to continue any other commands in the chain.

  • Twitter
  • Bookmark stop psql on first error at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg stop psql on first error
  • Bloglines stop psql on first error
  • Technorati stop psql on first error
  • Fark this: stop psql on first error
  • Bookmark stop psql on first error at YahooMyWeb
  • Bookmark stop psql on first error at Furl.net
  • Bookmark stop psql on first error at reddit.com
  • Bookmark stop psql on first error at blinklist.com
  • Bookmark stop psql on first error at Spurl.net
  • Bookmark stop psql on first error at Simpy.com
  • Bookmark stop psql on first error at blogmarks
  • Bookmark stop psql on first error with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca