当前位置:Gxlcms > 数据库问题 > shell访问postgresql,copy入库,调用函数

shell访问postgresql,copy入库,调用函数

时间:2021-07-01 10:21:17 帮助过:20人阅读

source $HOME/.bash_profile

PRE_DATE=`date +"%Y-%m-%d" -d "-1days"`

if [ $# -ne 0 ];then
PRE_DATE=$1;
fi

python test5.py $PRE_DATE

echo "delete from lsb_cbh_test;"> test1.sql
psql "host=10.100.0.254 hostaddr=10.100.0.254 port=5433 user=sys_report password=report2hhl dbname=sysreport" -f test1.sql

#echo "\COPY lsb_cbh_test FROM ‘test_1.csv‘ delimiter as‘,‘ NULL as ‘null‘ ;">test.sql
echo "\COPY lsb_cbh_test(type_id,cuid) FROM ‘test11_new.txt‘ delimiter as‘,‘ ;">test.sql
psql "host=10.100.0.254 hostaddr=10.100.0.254 port=5433 user=sys_report password=report2hhl dbname=sysreport" -f test.sql

v_date=`echo $PRE_DATE|sed ‘s/-//g‘`
echo "select sp_stat_client_visit(‘$v_date‘);" >test2.sql
psql "host=10.100.0.254 hostaddr=10.100.0.254 port=5433 user=sys_report password=report2hhl dbname=sysreport" -f test2.sql

shell访问postgresql,copy入库,调用函数

标签:csv   gre   profile   null   epo   调用   limit   rom   pre   

人气教程排行