Re: [SQL] a script that queries database periodically
Peter Eisentraut <peter_e@gmx.net>
From: Peter Eisentraut <peter_e@gmx.net>
To: Bernie Huang <bernie.huang@ec.gc.ca>
Cc: PGSQL-GENERAL <pgsql-general@postgresql.org>
Date: 2000-11-27T22:24:55Z
Lists: pgsql-general, pgsql-sql
Bernie Huang writes: > My boss wants me to write a script that will send a email report to him > monthly with the result of database queries. > I guess a shell script is necessary. So, is it possible to call > 'psql' and returning its query result and I can use sendmail to email > the result? Any other idea? Conceptually, what you want is something like this: #! /bin/sh ( echo "Here's your report:" psql -c 'SELECT ...' ) | mail -s Subject foo@bar Reading man pages on each of these is advisable. -- Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/