# status_value **Repository Path**: initialdream1659/status_value ## Basic Information - **Project Name**: status_value - **Description**: 使用pymysql统计机组条数,来判定机组上线情况。主要练习 sql 语句。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-12-18 - **Last Updated**: 2024-07-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 1. pip 使用库说明 库 | 版本 --- | --- pymysql | time | datetime | ## 2. 运行 首先运行 MultiTableOperator.py,生成新表,再添加 TimeMultiTableOperator.py 至 229 服务器后台运行,用于每日定时操作。 ## 3. [linux 后台运行 py 程序](https://www.jb51.net/article/156969.htm) 在指定文件夹下添加 start.sh ``` #!/bin/bash cd beijing_huairou_dayvalue_statistics python3 -u TimeMultiTableOperator.py ``` 添加权限 ``` sudo chmod 777 ./start.sh ``` 添加至后台运行 ``` ./start.sh > result.log & ``` 运行第二天查看有如下问题:后台运行 Python 程序已经自动退出([可能原因是:当前终端shell的进程为父进程,而父进程一旦退出,则会发送hangup信号给所有子进程,子进程收到hangup以后也会退出](https://www.cnblogs.com/sunlong88/articles/10438235.html))。[改进:](https://my.oschina.net/u/4305544/blog/3563932) [后台运行命令解释](https://blog.csdn.net/vitaminc4/article/details/78768108) ``` nohup ./start.sh > result.log & ``` 查看后台进程 ``` ps -e ps -aux ``` 查看当前终端后台运行的任务 ``` jobs ``` 关闭当前后台运行的命令 ``` kill -9 PID ``` ## 4. [Windows 后台运行 py 文件](https://www.cnblogs.com/andy9468/p/9676719.html) 添加 start_show.bat、start_hidden.vbs、stop_all_python.bat,通过双击运行。 有一个弊端是:Windows 服务器需要长期开机。 ``` start_show.bat python TimeMultiTableOperator.py start_hidden.vbs Set ws = CreateObject("Wscript.Shell") ws.run "cmd /c start_show.bat",0 stop_all_python.bat taskkill /IM python.exe /F ``` ## 5. 一些 sql 语句 对 linker_iuid和小时分组求均值: ``` select linker_iuid, word_1 as model, DATE_FORMAT(transfer_time, '%H') as hour, count(DATE_FORMAT(transfer_time, '%H')) as count, sum(word_18) as sum_ExTemp, sum(word_18)/count(DATE_FORMAT(transfer_time, '%H')) as mean_ExTemp from data_protocol_xxxxxx where word_1 = 1 group by linker_iuid,DATE_FORMAT(transfer_time, '%H'); ``` # 一些参考资料 ## 一些 sql 操作 1. [指定字符分割或删除特定字符](https://whoami.blog.csdn.net/article/details/107923739) 2. [表连接查询](https://www.cnblogs.com/feigebaqi/p/9223992.html) 3. [where 子句](https://www.runoob.com/mysql/mysql-where-clause.html) 4. [对某列计数](https://blog.csdn.net/gusijin/article/details/105855530) 5. [分组](https://www.cnblogs.com/niyl/p/9650183.html) 6. [查询数据库名和表名](https://blog.csdn.net/u012643122/article/details/44039155) 7. [多行合并](https://blog.csdn.net/rainyspring4540/article/details/50231435) 8. [字符串截取总结](https://www.cnblogs.com/heyonggang/p/8117754.html) 9. [select 新增字段](https://www.cnblogs.com/-beyond/p/8487512.html) 10. [MySQL 查询结果中字段的字符个数超过指定长度时截取到指定长度并追加省略号](https://blog.csdn.net/wzy999157/article/details/80856164) 11. [字段修改](https://www.cnblogs.com/jnhs/p/10046832.html) 12. [查询结果新建表](https://blog.csdn.net/qq_39321542/article/details/89019374) 13. [python 后台启动](https://blog.csdn.net/weixin_30530339/article/details/94820536?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3.control) 14. [Linux 查看和关闭后台运行程序的方法](https://www.cnblogs.com/forforever/p/14089948.html) 15. [linux 查看和关闭后台运行程序操作](https://www.cnblogs.com/presleyren/p/10966148.html) 16. [Linux下后台运行程序及终止程序](https://www.cnblogs.com/kon-bai/p/12321808.html) 17. [python 定时器](https://www.jb51.net/article/156624.htm) 18. [Python 每天定时执行某段程序代码](https://www.jb51.net/article/167777.htm) 19. [mysql时间相加函数DATE_ADD()](https://www.cnblogs.com/hanfengyeqiao/p/9471546.html) ## 一些 bug 说明 1. [Linux下解决permission denied问题](https://www.cnblogs.com/tomfang/p/5704466.html) 2. [nohup: ignoring input and appending output to ‘nohup.out’](https://blog.csdn.net/qq_37788081/article/details/83825918) 3. [affected_rows](https://blog.csdn.net/koastal/article/details/74783278) 4. ["Incorrect date value: '1983' for column 'crawl_date' at row 1"](https://blog.csdn.net/weixin_40530363/article/details/97651385) ## 其他资料 1. [私有仓库GitLab快速入门篇](https://www.cnblogs.com/yinzhengjie/p/9568657.html) 2. [svn和git的区别及适用场景](https://blog.csdn.net/wz947324/article/details/80104621?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3.control) 3. [本地配置多个ssh](https://blog.csdn.net/candy_mi/article/details/106940022)