我正在运行一个名为MyCode.py的python程序,它使用pymysql连接到AWS数据库并从中拉出来。当我在shell中使用Jenkins运行它时,python包已成功安装,但是pmyysql连接无法连接并在调用MyCode.py后超时。当我通过Mac OSx终端运行MyCode.py时,它运行完美,可以成功从数据库中取出。不知道我用来调用我的python脚本的代码是否会破坏pymysql的连接?
Jenkins shell脚本:
ls -la
virtualenv FullTests
. FullTests/bin/activate
pip install pandas
pip install pymysql
pip install logger
pip install requests
ls -la
python FullTests.py
deactivate
MyCode.py(Snippet)
conn = pymysql.connect(host='production-cluster.cluster123-east-1.rds.amazonaws.com', port=3306, user='reader', passwd='somepassword, db='metrics', connect_timeout=10)
cur = conn.cursor()
cur.callproc('metrics.GetReaderData')
result = cur.fetchall()
return result