任务:每日下午五点半统计数据,发送给领导。
人工流程:Windows10上通过ODBC连接远程生产Cache数据库,在sqlDbx执行sql语句,得到数据后填到模板,微信发给领导。
自动流程:
1.安装python3.7.8(注意坑,python3.7.4会setup报错)
2.按照Cache提供的python调用说明,操作一下步骤:
1) Install Cache'
2) Make sure CACHE_INSTALL_DIR/bin (or CACHE_INSTALL_DIR\bin) is on your path (Your CACHE_INSTALL_DIR might be /usr/cachesys/bin.)
3) Update LD_LIBRARY_PATH (LINUX only)
4) Update DYLD_LIBRARY_PATH instead of LD_LIBRARY_PATH (MAC only)
4) Setup your enviornment to use Microsoft or LINUX C/C++ compiler
5) Invoke python extension setup command (python setup.py install)
6) Test by invoking python test
3.环境搭建好后,编写调用数据库和发送邮件的py脚本。
import smtplib
from email.mime.text import MIMEText
from email.header import Header
import codecs, sys
import intersys.pythonbind3
import datetime
id = 1;
user = "_user";
password = "pwd";
host = "localhost";
port = "1972";
query = "A";
numList=[];
args = sys.argv[1:]
index = 0
while 1:
if index >= len(args): break
arg = args[index]
if arg == "-user":
index += 1
user = args[index]
elif arg