'pyodbc An internal error occurred that prevents further processing of this command: 'Object reference not set to an instance of an object.'
I have a python script which uses pyodbc to connect a Microsoft SQL Server (SQL Pool indeed) and executes a COPY INTO statement on a daily basis. It has been working fine for months but last week suddenly started to crash returning the abovementioned error. I haven't made any change, the statement still executing fine if I run it directly on the server but not by code.
The purpose of the script is to perform a COPY INTO operation from an Azure Data Lake file which gets loaded every day to the SQl Server. Again as I said I have already tryied executing the command on the server and trying to load previous versions of the file but the error keeps appearing and it is not very descriptive.
This is the piece of code that throws the error:
If I try to change the statement with a table that does not exists or with an invalid file name the error changes appropiately to invalid object name for example, so the connection is okay imo. And I have tryied to execute the statement without passing variables to the string as well
Thanks in advance.
Solution 1:[1]
Just in case someone faces a similar issue. It was resolved after setting pyodbc connection autocommit to True.
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 | g98vlc19d |

