Friday, January 31, 2014

How To: "Watch" a PSQL table from the command line

Follow this procedure to use watch with a psql query from a Linux command prompt:
  • Create a .pgpass file as follows:
    • vi /root/.pgpass
    • Fill in the file as follows:
*:*:<username>:<password>
  • Execute the command:
chmod 0600 /root/.pgpass
  •  Execute the command:
watch 'psql -c "insert_query_here;" -U <username> <database_name>'

No comments:

Post a Comment