Re: [SQL] a script that queries database periodically - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: [SQL] a script that queries database periodically
Date
Msg-id Pine.LNX.4.21.0011272323020.832-100000@peter.localdomain
Whole thread Raw
List pgsql-general
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/


pgsql-general by date:

Previous
From: "Poul L. Christiansen"
Date:
Subject: Re: [SQL] a script that queries database periodically
Next
From: Partyka Robert
Date:
Subject: one ask