开发者

Can I execute an SQL Server DTS package from a Python script?

开发者 https://www.devze.com 2022-12-09 03:49 出处:网络
I curr开发者_Go百科ently have a number of Python scripts that help prep a staging area for testing. One thing that the scripts do not handle is executing DTS packages on MS SQL Server. Is there a way

I curr开发者_Go百科ently have a number of Python scripts that help prep a staging area for testing. One thing that the scripts do not handle is executing DTS packages on MS SQL Server. Is there a way to execute these packages using Python?


The answer is yes. As mentioned by lansinwd, you'd want to use the command line tool DTSRun. SQL Server tools will need to be installed on the machine executing the Python script. I'm not sure what percentage or which packages would be needed but the MSDN page on DTSRun should help answer that, if needed.

A basic command line example is this:

DTSRun /S "Server[\Instance]" /N "DTS_Package_Name" /E

To run this from Python check out: http://docs.python.org/library/os.html#process-management

From the web page:

These functions may be used to create and manage processes.

The various exec*() functions take a list of arguments for the new program loaded into the process


Is calling the DTS run from the command line an option. If so here is an example for that.

http://www.mssqltips.com/tip.asp?tip=1007

0

精彩评论

暂无评论...
验证码 换一张
取 消