'Executing MSSQL File from Python 3.9 [closed]
I have a large SQL script which is too large to run from SQL Server Management Studio.
Is there a way to run such a script using Python?
SQLite3 doesn't seem to work. I keep getting syntax errors but the query is standard SQL.
Is there an MSSQL equivalent library in Python?
Solution 1:[1]
Use cursor from a pyodbc connection.
cursor.execute(<sql code as string>)
cursor.commit()
If you use sqlalchemy, you can get the cursor from engine as follows:
engine.raw_connection().cursor()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dale K |
