Execute .sql files that are used to run in SQL Management Studio in python -
as part of artifacts delivery, our developers give data , structure scripts in .sql files. "double click" on these files open in "microsoft sql server management studio". management studio prompt me entering database server , user/pwd. enter them manually , click on execute button execute these scripts.
these scripts contain structure , data sql commands. each script may contain more 1 data command (like select, insert, update, etc). structure , data scripts provided in separate .sql files.
these scripts contain stored procedures , functions, etc. contain comments / description.
i want automate execution of these scripts through python. looked @ pyodbc , pymssql dont solve issue. through pyodbc, need read each .sql file , read sql commands , execute them 1 one. files may have comments / description / sps / etc, reading files little difficult.
can give suggestion on how automate this?
thanks in advance.
you run them using sqlcmd. sqlcmd command line utility let run .sql
scripts command line, i'm sure can kick off through python.
Comments
Post a Comment