Skip site navigation (1) Skip section navigation (2)

Re: [SQL] a script that queries database periodically

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bernie Huang <bernie(dot)huang(at)ec(dot)gc(dot)ca>
Cc: PGSQL-GENERAL <pgsql-general(at)postgresql(dot)org>
Subject: Re: [SQL] a script that queries database periodically
Date: 2000-11-27 22:24:55
Message-ID: Pine.LNX.4.21.0011272323020.832-100000@peter.localdomain (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-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(at)bar

Reading man pages on each of these is advisable.

-- 
Peter Eisentraut      peter_e(at)gmx(dot)net       http://yi.org/peter-e/


In response to

pgsql-sql by date

Next:From: JasonDate: 2000-11-27 22:36:40
Subject: Re: [PHP-DB] Re: [SQL] a script that queries database periodically
Previous:From: Roberto MelloDate: 2000-11-27 21:56:59
Subject: Re: [SQL] a script that queries database periodically

pgsql-general by date

Next:From: Callis, AdamDate: 2000-11-27 22:27:25
Subject: I got Pl/Perl working on Solaris!
Previous:From: Partyka RobertDate: 2000-11-27 22:24:46
Subject: one ask

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group