Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspectdb errors and support schemas for MSSQL #3

Open
amanjeev opened this issue Dec 12, 2014 · 4 comments
Open

Inspectdb errors and support schemas for MSSQL #3

amanjeev opened this issue Dec 12, 2014 · 4 comments

Comments

@amanjeev
Copy link

Please correct me if I missed this in the wrapper or the original library. I understand that this is a wrapper to django-mssql but I was wondering if this is a better starting place to ask this. We have a rather large database with at least three different schemas. It seems to me that while running inspectdb, schemas are not supported. I think it will be helpful to use Schemas as they are an integral part of the MSSQL databases.

Moreover, running inspectdb on my database returns errors for the first table itself even if the table is given all permissions for anyone. I tried running myschem.PROD_DONE as well but that also gave the same error.

Traceback (most recent call last):
  File "manage.py", line 9, in <module>
    execute_from_command_line(sys.argv)
  File "env/lib/python3.3/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "env/lib/python3.3/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "env/lib/python3.3/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "env/lib/python3.3/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "env/lib/python3.3/site-packages/django/core/management/base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "env/lib/python3.3/site-packages/django/core/management/commands/inspectdb.py", line 27, in handle_noargs
    for line in self.handle_inspection(options):
  File "env/lib/python3.3/site-packages/django/core/management/commands/inspectdb.py", line 62, in handle_inspection
    relations = connection.introspection.get_relations(cursor, table_name)
  File "env/lib/python3.3/site-packages/sqlserver_ado/introspection.py", line 142, in get_relations
    source_field_dict = self._name_to_index(cursor, table_name)
  File "env/lib/python3.3/site-packages/sqlserver_ado/introspection.py", line 139, in _name_to_index
    return dict([(d[0], i) for i, d in enumerate(self.get_table_description(cursor, table_name, False))])
  File "env/lib/python3.3/site-packages/sqlserver_ado/introspection.py", line 109, in get_table_description
    cursor.execute("SELECT * FROM [%s] where 1=0" % (table_name))
  File "env/lib/python3.3/site-packages/django/db/backends/util.py", line 69, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "env/lib/python3.3/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "env/lib/python3.3/site-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "env/lib/python3.3/site-packages/django/utils/six.py", line 549, in reraise
    raise value.with_traceback(tb)
  File "env/lib/python3.3/site-packages/django/db/backends/util.py", line 51, in execute
    return self.cursor.execute(sql)
  File "env/lib/python3.3/site-packages/pytds/__init__.py", line 879, in execute
    self._execute(operation, params)
  File "env/lib/python3.3/site-packages/pytds/__init__.py", line 608, in _execute
    self._session.find_result_or_done()
  File "env/lib/python3.3/site-packages/pytds/tds.py", line 3455, in find_result_or_done
    self.process_end(marker)
  File "env/lib/python3.3/site-packages/pytds/tds.py", line 2653, in process_end
    self.raise_db_exception()
  File "env/lib/python3.3/site-packages/pytds/tds.py", line 2442, in raise_db_exception
    raise ex
django.db.utils.ProgrammingError: Invalid object name 'PROD_DONE'.

Edit: More information -

Running SELECT * FROM myschem.PROD_DONE where 1=0 directly in the SQL serer studio does not give any error but while inspectdb runs, this line https://bitbucket.org/Manfre/django-mssql/src/8ac825580d01c653256d21931e87caf3aa3513fb/sqlserver_ado/introspection.py?at=stable/1.6#cl-109 fails.

@amanjeev
Copy link
Author

@denisenkom
Copy link
Owner

Can you provide full command with parameters? e.g. python manage.py inspectdb

@amanjeev
Copy link
Author

Mostly this -

python manage.py inspectdb --database=mydbname

@nsuman
Copy link

nsuman commented Jan 12, 2018

Did they provide any fix for this issue? I am having the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants