mkleehammer / pyodbc

Python ODBC bridge
https://github.com/mkleehammer/pyodbc/wiki
MIT No Attribution
2.88k stars 562 forks source link

Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13 for SQL Server' : file not found (0) (SQLDriverConnect)") #1150

Closed J04N4 closed 1 year ago

J04N4 commented 1 year ago

Please first make sure you have looked at:

Environment

To diagnose, we usually need to know the following, including version numbers. On Windows, be sure to specify 32-bit Python or 64-bit:

Issue

I'm using pyodbc to establish connection to sql db in my python code. Everything works fine locally, but when I deploy the Function App and I run it on the Azure Portal, I get the "Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13 for SQL Server' : file not found (0) (SQLDriverConnect)")". error

error

I installed the driver locally on my Windows machine and I installed and imported pyodbc on my python environment. The OS used in the function app environment is Linux Often it is easiest to describe your issue as "expected behavior" and "observed behavior".

gordthompson commented 1 year ago

Check the list returned by pyodbc.drivers() to see what ODBC drivers are available to your Python app on the Azure Portal.

J04N4 commented 1 year ago

@gordthompson On my local machine i have the following ODBC drivers:

drivers
gordthompson commented 1 year ago

Fine, but that does not tell you anything about the drivers that are — or are not — installed on the other machine (to which you deploy your application).

J04N4 commented 1 year ago

@gordthompson The Function App is associated to an App Service Plan that is Consumption (serverless) and runs on Linux. I don't think I can manage or install things on those, not to my knowledge

gordthompson commented 1 year ago

Well, that environment seems to have pyodbc installed so they may have already provided some version of msodbcsql ("ODBC Driver xx for SQL Server"). pyodbc.drivers() on the remote system would tell you that.

J04N4 commented 1 year ago

@gordthompson It seems like they had the odbc driver 17 for sql server installed by default on the container. I change it in my code to match it and it fixed. image

Thank you for the explanation