一睹欲、項目介紹
1.1項目需求
基于第一部分業(yè)務(wù)背景供炼,公司為加強線上業(yè)務(wù)數(shù)據(jù)化方面的治理,讓業(yè)務(wù)部門能夠?qū)崿F(xiàn)自主分析從而實現(xiàn)對市場的快速判斷窘疮,現(xiàn)需使用Python袋哼、數(shù)據(jù)倉庫實現(xiàn)自動更新式可視化看板。
1.2項目操作流程
1.3項目流程框架
根據(jù)上述項目介紹闸衫,以下主要從數(shù)倉獲取數(shù)據(jù)涛贯、自動化py腳本處理、可視化報表搭建蔚出、自動化更新看板數(shù)據(jù)四方面簡要介紹下操作過程弟翘。
二、簡要操作過程
1骄酗、數(shù)倉獲取數(shù)據(jù)
(1)操作概要
Python通過配置文件database.py中稀余,連接mysql中的ods數(shù)據(jù)庫抽取數(shù)據(jù)。
(2)操作過程
數(shù)倉獲取數(shù)據(jù)
2趋翻、自動化py腳本處理
(1)操作概要
通過Python對ods基礎(chǔ)數(shù)據(jù)層數(shù)據(jù)進行加工處理睛琳,生成相應(yīng)的dw報表。
(2)操作過程
dw_order_by_day.py(每日銷售匯總&環(huán)比表)
dw_order_diff.py(每日銷售同比表)
dw_customer_order.py(每日時間產(chǎn)品地區(qū)聚合表-流水表)
3、可視化報表搭建
(1)操作概要
主要從時間掸掏、地區(qū)茁影、產(chǎn)品等維度,設(shè)計銷售額丧凤、訂單量募闲、客單價、同環(huán)比等關(guān)鍵性指標愿待,實現(xiàn)銷售總體情況浩螺,銷售時間趨勢、銷售區(qū)域分布的可視化報表展示仍侥。
(2)操作過程
銷售總體情況展示:
銷售時間趨勢展示:
銷售時間趨勢展示
銷售區(qū)域分布展示:
4要出、自動化更新看板數(shù)據(jù)
(1)操作概要
通過linux服務(wù)器上部署代碼,并通過powerbi連接相應(yīng)mysql數(shù)據(jù)庫實現(xiàn)每日定時更新數(shù)據(jù)
(2)操作過程
Xshell登錄百度云服務(wù)器,進行l(wèi)inux相關(guān)命令操作:
1农渊、進入并查看文件夾下信息
cd aventure_Ben
ls
(base) [frog005@instance-grq6ue3x ~]$ cd adventure_Ben
(base) [frog005@instance-grq6ue3x adventure_Ben]$ ls
Ben_logs dw_order_by_day_multiprocessing.py dw_order_diff.py log.py schedule_job_Ben.log select_data_by_multiprocessing.py
database.py dw_order_by_day.py insert_data_by_multiprocessing.py __pycache__ schedule_job_Ben.py update_sum_data.py
2患蹂、查看schedule程序目前運行情況
ps aux| grep schedule_job_Ben.py
(base) [frog005@instance-grq6ue3x adventure_Ben]$ ps aux| grep schedule_job_Ben.py
frog005 1342 0.0 0.0 112708 972 pts/1 S+ 16:52 0:00 grep --color=auto schedule_job_Ben.py
此時沒有程序掛起
3、將schedule程序掛在后臺執(zhí)行砸紊,并輸出日志:
nohup python3 schedule_job_Ben.py > schedule_job_Ben2.log 2>&1 &
(base) [frog005@instance-grq6ue3x adventure_Ben]$ nohup python3 schedule_job_Ben.py > schedule_job_Ben2.log 2>&1 &
[1] 1409
掛在后臺的程序代號為1409
4传于、查看該schedule程序目前運行情況(驗證是否順利掛在后臺?)
ps aux| grep schedule_job_Ben.py
(base) [frog005@instance-grq6ue3x adventure_Ben]$ ps aux| grep schedule_job_Ben.py
frog005 1409 0.9 0.2 150832 23072 pts/1 S 16:57 0:00 python3 schedule_job_Ben.py
程序順利掛在后臺醉顽,代號為1409的程序等待運行沼溜。
5、時間已過schedule程序定時時間,查看該schedule程序目前運行情況
ps aux| grep schedule_job_Ben.py
(base) [frog005@instance-grq6ue3x adventure_Ben]$ ps aux| grep schedule_job_Ben.py
frog005 21944 0.0 0.2 151000 18708 ? S Jun28 0:24 python3 schedule_job_Ben.py
frog005 1409 0.0 0.0 112708 972 pts/1 S+ 16:58 0:00 grep --color=auto schedule_job_Ben.py
程序運行結(jié)束
6游添、查看相關(guān)程序日志情況
cat update_sum_data.log
后臺程序運行成功,PowerBI每日刷新實現(xiàn)數(shù)據(jù)更新系草。