How to Execute Python Script as Administrator in SQL Server Agent Job

前端 未结 2 1204
攒了一身酷
攒了一身酷 2021-01-14 03:33

I have a Python (3.7.2) file that pulls data from a third party API, saves the data in a local CSV file on Windows Server 2016

相关标签:
2条回答
  • 2021-01-14 04:18

    Did you try using sp_execute_external_script ?

    execute sp_execute_external_script 
    @language = N'Python', 
    @script = N'
    a = 1
    b = 2
    c = a/b
    d = a*b
    print(c, d)
    '
    

    For example, this code can be scheduled into SqlAgent.

    0 讨论(0)
  • 2021-01-14 04:19

    I was able to solve the problem to my question by adding a credential/proxy account, assigning it to the Run as in the step, and then altering the Command to look like this:

    C:\Windows\System32\cmd.exe /C python "C:\PythonScripts\myPython.py"

    0 讨论(0)
提交回复
热议问题