Closed sharathsridhar closed 1 year ago
4.0.34 was broken because it contains old version of unixODBC. Try a previous version of pyODBC. You can also try strace'ing the connect to see what file it doesn't find.
@v-chojas Thank you.
4.0.30
- File not found errorSo it works when using isql
but when using the same connection string in Python it gives the file not found error?
@v-makouz Yes, when using isql
from within Docker terminal, it connects, but when the execution comes to the below lines,
sourceDbConnectionString = 'DRIVER={ODBC Driver 17 for SQL Server}; SERVER=%s; Database=%s; UID=%s; PWD=%s; MARS_Connection=Yes' \
% ( self.sourceDbServer, self.sourceDb, self.sqlServerUserName
, self.sqlServerPassword)
sourceDbConnection = pyodbc.connect(sourceDbConnectionString)
it does not connect and throws the file not found
error
Run strace on the Python process and it should tell you what file is not found in the output.
@v-chojas Sorry, I don't know how to run strace from within Docker/terminal. Could you please tell me how or which commands to run?
Please read the man page first.
I will read and get back to you. Please do not close this ticket.
@sharathsridhar - Any progress?
Environment
(All versions/instances within Docker. SQL Server is also running from Docker)
Issue
Observed Behavior
Dockerfile
Connectionstring
- error occurs hereisql
- Connection Successful from Docker TerminalFile exists when command
ls -la /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.10.so.1.1
is runodbcinst -j
pyodbc.drivers()
returns['ODBC Driver 17 for SQL Server']
cat /etc/odbcinst.ini
Error
'01000', \"[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)
Followed instruction from (https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#ubuntu17) to install ODBC 17 on Ubuntu
Expected Behavior
To be able to connect to MS SQL Server/databases without any errors, but currently the error, as mentioned, pops up
This error does not occur when running the code in PyCharm (outside docker) which has PyODBC installed and is running Python 3.7, but fails from within Docker. Am I missing something obvious in the Dockerfile/Python code?
Thank you.