#!/bin/bash
#will copy data from postgres db1 table into db 2 table
#usage is pg_trans.sh db1 db2 table


if [ $# -lt 3 ]
then
echo "Usage is: `basename $0` db1 db2 table"
exit 2
fi

db1=$1
db2=$2
table=$3

tmpfile=`mktemp`
chmod 666 $tmpfile
psql -c "copy $table to '$tmpfile'" -d $db1
psql -c "copy $table from '$tmpfile'" -d $db2
rm $tmpfile
