sql
This commit is contained in:
48
scripts/onetime_compile.sh
Executable file
48
scripts/onetime_compile.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash -e
|
||||
HOME="/home/compegence/customer"
|
||||
#Directories
|
||||
homeDir=$HOME/MMT
|
||||
configDir=$homeDir/conf
|
||||
input_file=$configDir/etl-config.txt
|
||||
declare -A credentials
|
||||
while IFS="=" read -r key value; do
|
||||
credentials[$key]=$value
|
||||
done < <( sed -e '/^\s*$/ d' -e '/^#/ d' $input_file )
|
||||
#for i in ${credentials[@]}; do echo ***$i; done
|
||||
|
||||
user=${credentials[user]}
|
||||
password=${credentials[password]}
|
||||
host=${credentials[host]}
|
||||
db=${credentials[db]}
|
||||
protocol=${credentials[protocol]}
|
||||
server=${credentials[server]}
|
||||
|
||||
mmt_con="psql -X -q -A -t postgresql://$user:$password@$host/$db?options=--search_path%3D"
|
||||
|
||||
declare -a archivepathvar=("$homeDir/sql/onetime/archive/schema")
|
||||
|
||||
declare -a archivepathsvar=("$homeDir/sql/onetime/archive/create" "$homeDir/sql/onetime/archive/function")
|
||||
|
||||
declare -a trxpathvar=("$homeDir/sql/onetime/createtables/common" "$homeDir/sql/onetime/createtables/ods" "$homeDir/sql/onetime/createtables/control" "$homeDir/sql/onetime/commonfunctions" "$homeDir/sql/onetime/configentries" "$homeDir/sql/onetime/dataloadfunctions/ODS_Load")
|
||||
|
||||
declare -a stgpathvar=("$homeDir/sql/onetime/createtables/staging" "$homeDir/sql/onetime/dataloadfunctions/budni" "$homeDir/sql/onetime/dataloadfunctions/Drawbar" "$homeDir/sql/onetime/dataloadfunctions/IHT" "$homeDir/sql/onetime/dataloadfunctions/field" "$homeDir/sql/onetime/dataloadfunctions/PTO" "$homeDir/sql/onetime/wrappers")
|
||||
|
||||
func_execute_conn(){
|
||||
local conn="$1"
|
||||
local -n param=$2
|
||||
for path in "${param[@]}"
|
||||
do
|
||||
for files in "$path"/*
|
||||
do
|
||||
$conn -f $files
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
func_execute_conn "$mmt_con'archive'" archivepathvar
|
||||
|
||||
func_execute_conn "$mmt_con'staging2'" stgpathvar
|
||||
|
||||
func_execute_conn "$mmt_con'trx'" trxpathvar
|
||||
|
||||
func_execute_conn "$mmt_con'archive'" archivepathsvar
|
||||
Reference in New Issue
Block a user