Invalid object name 'table'

I have a few bases in my project. Hence I need to redefine methods which get some information from base. Everything had worked fine until I decided to authorize via active directory. Finally I get this: authorization works (default database), requests to database that is not default fails. Authorization info is stored in PostgreSQL database. Data is stored in MSSQL database. Django-ajax-datatable is response for render data from MSSQL database.

I get error ProgrammingError at /admin/app/table/

('42S02', "[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'table'. (208) (SQLExecDirectW)")

Environment:


Request Method: GET
Request URL: http://localhost:8000/admin/app/table/

Django Version: 3.2.14
Python Version: 3.10.5
Installed Applications:
['app.apps.CrmConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'debug_toolbar',
'django_filters',
'bootstrap3',
'ajax_datatable']
Installed Middleware:
['debug_toolbar.middleware.Debu gToolbarMiddleware',
'django.middleware.security.Se curityMiddleware',
'django.contrib.sessions.middl eware.SessionMiddleware',
'django.middleware.common.Comm onMiddleware',
'django.middleware.csrf.CsrfVi ewMiddleware',
'django.contrib.auth.middlewar e.AuthenticationMiddleware',
'django.contrib.messages.middl eware.MessageMiddleware',
'django.middleware.clickjackin g.XFrameOptionsMiddleware']



Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.10/site-packages/mssql/base.py", line 598, in execute
return self.cursor.execute(sql, params)

The above exception (('42S02', "[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'table'. (208) (SQLExecDirectW)")) was the direct cause of the following exception:
File "/usr/local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.10/site-packages/django/contrib/admin/options.py", line 616, in wrapper
return self.admin_site.admin_view(vie w)(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/django/contrib/admin/sites.py", line 232, in inner
return view(request, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/django/contrib/admin/options.py", line 1697, in changelist_view
cl = self.get_changelist_instance(r equest)
File "/usr/local/lib/python3.10/site-packages/django/contrib/admin/options.py", line 736, in get_changelist_instance
return ChangeList(
File "/usr/local/lib/python3.10/site-packages/django/contrib/admin/views/main.py", line 100, in __init__
self.get_results(request)
File "/usr/local/lib/python3.10/site-packages/django/contrib/admin/views/main.py", line 235, in get_results
result_count = paginator.count
File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.10/site-packages/django/core/paginator.py", line 97, in count
return c()
File "/usr/local/lib/python3.10/site-packages/django/db/models/query.py", line 412, in count
return self.query.get_count(using=sel f.db)
File "/usr/local/lib/python3.10/site-packages/django/db/models/sql/query.py", line 528, in get_count
number = obj.get_aggregation(using, ['__count'])['__count']
File "/usr/local/lib/python3.10/site-packages/django/db/models/sql/query.py", line 513, in get_aggregation
result = compiler.execute_sql(SINGLE)
File "/usr/local/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python3.10/site-packages/debug_toolbar/panels/sql/tracking.py", line 230, in execute
return self._record(self.cursor.execu te, sql, params) 
File "/usr/local/lib/python3.10/site-packages/debug_toolbar/panels/sql/tracking.py", line 154, in _record
return method(sql, params)
File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 98, in execute
return super().execute(sql, params)
File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sq l, params, many=False, executor=self._execute)
File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 79, in _execute
with self.db.wrap_database_errors:
File "/usr/local/lib/python3.10/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(tr aceback) from exc_value
File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.10/site-packages/mssql/base.py", line 598, in execute
return self.cursor.execute(sql, params)

Exception Type: ProgrammingError at /admin/app/table/
Exception Value: ('42S02', "[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL 
Server]Invalid object name 'table'. (208) (SQLExecDirectW)")

As for me there is nothing interesting in my traceback so can you say anything? What can cause this error? AThere is nothing connected with data in MSSQL database in django-auth-ldap.

Problem was with environment variables in docker-compose. Facepalm

Back to Top