一、项目介绍
1.1项目需求
基于第一部分业务背景,公司为加强线上业务数据化方面的治理,让业务部门能够实现自主分析从而实现对市场的快速判断,现需使用Python、数据仓库实现自动更新式可视化看板。
1.2项目操作流程
1.3项目流程框架
根据上述项目介绍,以下主要从数仓获取数据、自动化py脚本处理、可视化报表搭建、自动化更新看板数据四方面简要介绍下操作过程。
二、简要操作过程
1、数仓获取数据
(1)操作概要
Python通过配置文件database.py中,连接mysql中的ods数据库抽取数据。
(2)操作过程
数仓获取数据
2、自动化py脚本处理
(1)操作概要
通过Python对ods基础数据层数据进行加工处理,生成相应的dw报表。
(2)操作过程
dw_order_by_day.py(每日销售汇总&环比表)
dw_order_diff.py(每日销售同比表)
dw_customer_order.py(每日时间产品地区聚合表-流水表)
3、可视化报表搭建
(1)操作概要
主要从时间、地区、产品等维度,设计销售额、订单量、客单价、同环比等关键性指标,实现销售总体情况,销售时间趋势、销售区域分布的可视化报表展示。
(2)操作过程
销售总体情况展示:
销售时间趋势展示:
销售区域分布展示:
4、自动化更新看板数据
(1)操作概要
通过linux服务器上部署代码,并通过powerbi连接相应mysql数据库实现每日定时更新数据
(2)操作过程
Xshell登录百度云服务器,进行linux相关命令操作:
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程序挂在后台执行,并输出日志:
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
程序运行结束
6、查看相关程序日志情况
cat update_sum_data.log
后台程序运行成功,PowerBI每日刷新实现数据更新。