catchWeatherFun()
{
for i in `curl -Ss http://www.nmc.cn/rest/weather?stationid=58154|jq -r '.data.passedchart[]|@base64'`
do
tempTime=`echo $i | base64 --decode | jq -r ".time"`
tempPressure=`echo $i | base64 --decode | jq -r ".pressure"`
#echo $tempTime
echo "INSERT INTO public.tbl_real_time_pressure (time,value)VALUES('"$tempTime"',"$tempPressure") ON CONFLICT (time) DO UPDATE SET value = "$tempPressure";" >> test.sql
done
}
echo "----------------start抓取天气-------------"
cd /opt/PostgreSQL-10/bin
catchWeatherFun
echo "-----------------write database!----------------"
cd /opt/PostgreSQL-10/bin
#psql -U postgres -d RealTimeData -a -f /opt/PostgreSQL-10/bin/test.sql
/opt/PostgreSQL-10/bin/psql -h IP -d RealTimeData -U postgres -p 5433 -a -q -f /opt/PostgreSQL-10/bin/test.sql
echo "---------------------rm test.sql-----------------"
#rm -rf test.sql
echo "-------------------- end!----------------"