I think my question is more or less duplicated Attempting to query SQL Server from django running on Linux - Unable to open lib '/path/to/libtdsodbc.so' , but the answer there is completely unhelpful.
I use the following things:
- Ubuntu 15.04
Python3Django 1.9 (installed via pip3)freetds-dev 0.91-6build1 installed via apt-getdjango-pyodbc-azure / django-pyodbc installed via pip3- MSSQL 2012
When I try to connect by executing python3 manage.py inspectdb , I get the following stack trace:
Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/base.py", line 199, in ensure_connection self.connect() File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/base.py", line 171, in connect self.connection = self.get_new_connection(conn_params) File "/usr/local/lib/python3.4/dist-packages/sql_server/pyodbc/base.py", line 302, in get_new_connection timeout=timeout) pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'FreeTDS' : file not found (0) (SQLDriverConnect)") The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 350, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 342, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/inspectdb.py", line 25, in handle for line in self.handle_inspection(options): File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/inspectdb.py", line 38, in handle_inspection with connection.cursor() as cursor: File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/base.py", line 231, in cursor cursor = self.make_debug_cursor(self._cursor()) File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/base.py", line 204, in _cursor self.ensure_connection() File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/base.py", line 199, in ensure_connection self.connect() File "/usr/local/lib/python3.4/dist-packages/django/db/utils.py", line 95, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/usr/local/lib/python3.4/dist-packages/django/utils/six.py", line 685, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/base.py", line 199, in ensure_connection self.connect() File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/base.py", line 171, in connect self.connection = self.get_new_connection(conn_params) File "/usr/local/lib/python3.4/dist-packages/sql_server/pyodbc/base.py", line 302, in get_new_connection timeout=timeout) django.db.utils.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'FreeTDS' : file not found (0) (SQLDriverConnect)")
I edited base.py to print the connection string that it uses, which:
DRIVER=FreeTDS;DATABASE=test;PWD=test;UID=sa;PORT=1433;SERVER=10.13.36.223
My settings.py settings for the database are as follows:
DATABASES = { 'default': { 'ENGINE': 'sql_server.pyodbc', 'NAME': 'test', 'USER': 'sa', 'PASSWORD': 'test', 'HOST': '10.13.36.223', 'PORT': '1433', 'AUTOCOMMIT': True, 'OPTIONS' : { 'host_is_server': True } } }
My assumption is that the DRIVER part of the str connection must be the full path to the executable for the odbc driver, and that it is now set to "FreeTDS", which does not exist as a file. My questions:
- If my assumption is correct, how to change the value for the driver?
- If my assumption is wrong, what is really wrong, and how can I solve it?