1

I have a Django site that is running on PostgreSQL and I'm attempting to pull some data from SQL Server in order to populate some form fields.

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

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

I've tried changing file and folder permissions but it's not got me anywhere, like I say I can connect via Python but not with Django.

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

manage.py shell

Any help is greatly appreciated.

UPDATE:

The file definitely exists, both Django and Python are using the same ODBC and FreeTDS config files.

I don't use virtualenv.

I did see a few references to /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so when I was performing the initial set up but I was under the impression that any issues that this could solve would prevent python from connecting also, would this not be the case?

UPDATE 2:

I've tried using pymssql and I'm getting similar results, it works through Python but with Django I'm getting this ImportError:

libct.so.4: cannot open shared object file: No such file or directory

UPDATE - SOLVED

@bradley.ayers comment in PIL - libjpeg.so.8: cannot open shared object file: No such file or directory pointed me in the right direction.

Community
  • 1
  • 1
Luke
  • 109
  • 2
  • 12
  • does this file really exists ? does `ls /path/to/libtdsodbc.so` show you the file ? do you use virtualenv ? –  Aug 28 '13 at 12:46
  • If you use ubuntu or similar try apt-file search libtdsodbc.so and install the package. tdsodbc: /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so – llazzaro Aug 28 '13 at 12:49
  • I would suggest to use http://code.google.com/p/pymssql/ it uses freedts directly – sherpya Aug 28 '13 at 12:57
  • 1
    If you you have solved your question, instead of adding "Solved" to your question title, please answer your own question and then accept that answer. – LittleBobbyTables - Au Revoir Oct 24 '13 at 18:45

2 Answers2

2

Apologies for the delay in answering, from what I remember I couldn't answer my own question due to having a new account:

@bradley.ayers comment in PIL - libjpeg.so.8: cannot open shared object file: No such file or directory pointed me in the right direction.

Thanks all for your help

Community
  • 1
  • 1
Luke
  • 109
  • 2
  • 12
  • for those of us who have the same issue, what was your solution? i added LD_LIBRARY_PATH, ran ldconfig, still getting same error – ierdna Jun 14 '17 at 00:18
  • Sorry Andrei I'm really struggling to remember any additional information – Luke Jun 16 '17 at 10:38
0

Probably you have change in your code the lib path "/path/to/libtdsodbc.so" in "/usr/lib/odbc/libtdsodbc.so" or otherwise the path where the file "libtdsodbc.so" has been placed.

Davide
  • 113
  • 2
  • 11
  • Thanks but "/path/to/libtdsodbc.so" isn't the actual path, I just used it as an example. – Luke Aug 28 '13 at 13:37