首页 > 解决方案 > Python 脚本不会在任务计划程序上运行

问题描述

我正在尝试让 python 脚本在任务调度程序上自动运行。

我从谷歌搜索中尝试了几个修复程序,但都没有奏效。

我当前的操作设置如下:

任务计划程序配置

我尝试了几种不同的操作设置组合,包括将脚本名称放入参数等。这些都没有奏效。

然后我在脚本中添加了一个代码,看看它有多远:

import logging, os

logpath = os.path.dirname(__file__)

logging.basicConfig(filename= logpath +'\\' +'logfile.log',level=logging.DEBUG,format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')

logging.info("The script was here")

该脚本一直运行,直到它必须连接到 SQL 服务器:

cnxn = pyodbc.connect("Driver={SQL Server Native Client 11.0};" "Server=dmadb;" "Database=db_DMA_MIDW_INS;" "Trusted_Connection=yes;")

有任何想法吗?

谢谢!

标签: pythonsqltaskscheduler

解决方案


推荐阅读