在SQL server实例中运行SQL脚本或SQL文件脚本的包
py-scripto的Python项目详细描述
py脚本
这是在SQLServer实例中运行SQL脚本或文件脚本
安装:
python -m pip install py_scripto
使用的版本
^{pr2}$依赖关系
DbExec存储过程
- 在
从https://github.com/datnguye/SQL-Server/blob/master/maintenance/DbExec.sql下载
在 - 在
编译到master数据库
在
xp\u cmdshell需要在SQL实例上启用
EXEC sp_configure 'show advanced option', 1
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE
GO
使用
from py_scripto import sqlserver
sqlserver.run_file_script(server="DAVID\DAVID", uid="py-scripto", pwd="py-scripto", connect_to_db="IMPORT", script_path="D:\\Downloads\\test.sql")
sqlserver.run_script(server="DAVID\DAVID", uid="py-scripto", pwd="py-scripto", connect_to_db="IMPORT", sql="SELECT * FROM Test WITH (NOLOCK)")
- 项目
标签: