0.029
thk thk Τρι. 16 Οκτ. 2018 16:21 1 σχόλια αποθήκευση (494 φορές)
I am doing again python postgresql migrating my booking app into hotelevropi.com

needed a script to transfer specific tables data

this script will copy data from postgres db1 table into db 2 table



#!/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