As part of the delivery of artifacts, our developers provide data scripts and structures in .sql files. I usually double-click on these files to open them in Microsoft SQL Server Management Studio. Management Studio will prompt me to enter the database server and user / pwd. I enter them manually and click the Execute button to execute these scripts.
These scripts contain sql structure and data commands. Each script can contain more than one data command (e.g. select, insert, update, etc.). Data structure and scripts are provided in separate .sql files.
These scripts also contain stored procedures and functions, etc. They also contain comments / descriptions.
I want to automate the execution of these scripts through python. I looked at pyobbc and pymssql, but they do not look like a solution to my problem. Through pyodbc, I need to read every .sql file and read the sql commands and execute them one by one. Since files may have comments / description / SPs / etc, reading files will be a bit difficult.
Can someone give a suggestion on how to automate this?
Thanks in advance.
Srinivas banda
source share