Trying to query SQL Server from django running on Linux - Unable to open lib '/path/to/libtdsodbc.so'

I have a Django site that runs on PostgreSQL, and I'm trying to extract some data from SQL Server to populate some form fields.

I can connect to SQL Server and query the database from a Linux server using Python with pyodbc and FreeTDS, and I got the impression that I can use the same connection string in the django view, but when I tried, I got the following error:

('01000', "[01000] [unixODBC] [Driver Manager] Unable to open lib '/path/to/libtdsodbc.so': file not found (0) (SQLDriverConnect)")

I tried changing permissions for files and folders, but it didn’t bother me, as I said, I can connect via Python, but not with Django.

I can also connect from the command line in the django application folder using

manage.py shell 

Any help is greatly appreciated.

UPDATE:

The file definitely exists, and Django and Python use the same ODBC and FreeTDS configuration files.

I do not use virtualenv.

I saw several links to /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so when I was doing the initial setup, but I got the impression that any problems that this could solve would not allow python to connect, not is not it?

UPDATE 2:

I tried using pymssql and I get similar results, it works through Python, but with Django I get this ImportError:

libct.so.4: cannot open shared objects file: no such file or directory

UPDATE - SOLVED

@ bradley.ayers comment in PIL - libjpeg.so.8: cannot open shared objects file: such a file or directory did not point me in the right direction.

+1
source share
3 answers

Sorry for the delay in the answer, from what I remember, I could not answer my question due to the availability of a new account:

@ bradley.ayers comment in PIL - libjpeg.so.8: cannot open shared objects file: such a file or directory did not point me in the right direction.

Thank you all for your help.

+2
source

@ user2725332 Sorry to post a response, not commenting on your answer - SO does not allow beginners to do this, so I suggest that this should be their preferred method for commenting.

You say that bradley.ayers pointed you in the right direction; It would be very helpful if you could tell us about the solution that worked for you. Did he add the directory containing your driver to the /etc/ld.so.conf file and then run ldconfig? This did not solve the problem in my post.

Thanks BH

+2
source

You probably have changes in your lib path code "/path/to/libtdsodbc.so" to "/usr/lib/odbc/libtdsodbc.so" or else the path where the libtdsodbc.so file was placed.

0
source

Source: https://habr.com/ru/post/1239080/


All Articles