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

django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The specified schema name "dbo" either does not exist or you do not have permission to use it. (2760) (SQLExecDirectW)')) #219

Open
harshacheemakurt opened this issue Jun 20, 2020 · 6 comments

Comments

@harshacheemakurt
Copy link

1.Connected to the Legacy Microsoft SQL server DB(hosted in Azure Cloud) in settings.py, connecting successful

  1. cmd: python manage.py inspect db, only captures models present in dbo schema, not capturing tables present in another schema of the database

3.when I do python manage.py migrate, throws below error

Note: all permissions provided for the User which I am connecting to Microsoft SQL server database( hosted in Azure)

django.db.utils.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The specified schema name "dbo" either does not exist or you do not have permission to use it. (2760) (SQLExecDirectW)'

complete error in my local windows machine

D:>python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Traceback (most recent call last):
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py", line 83, in _execute
return self.cursor.execute(sql)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\sql_server\pyodbc\base.py", line 546, in execute
return self.cursor.execute(sql, params)
**pyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The specified schema name "dbo" either does not exist or you do not have permission to use
it. (2760) (SQLExecDirectW)')

The above exception was the direct cause of the following exception:**

Traceback (most recent call last):
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\migrations\recorder.py", line 55, in ensure_schema
editor.create_model(self.Migration)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\sql_server\pyodbc\schema.py", line 591, in create_model
self.execute(sql, params or None)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\sql_server\pyodbc\schema.py", line 653, in execute
cursor.execute(sql, params)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py", line 100, in execute
return super().execute(sql, params)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\utils.py", line 89, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py", line 83, in _execute
return self.cursor.execute(sql)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\sql_server\pyodbc\base.py", line 546, in execute
return self.cursor.execute(sql, params)
**django.db.utils.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The specified schema name "dbo" either does not exist or you do not have permissio
n to use it. (2760) (SQLExecDirectW)')

During handling of the above exception, another exception occurred:**

Traceback (most recent call last):
File "manage.py", line 15, in
execute_from_command_line(sys.argv)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management_init_.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management_init_.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 353, in execute
output = self.handle(*args, **options)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\migrate.py", line 203, in handle
fake_initial=fake_initial,
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\migrations\executor.py", line 91, in migrate
self.recorder.ensure_schema()
File "C:\Users\975418\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\migrations\recorder.py", line 57, in ensure_schema
raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The specified
schema name "dbo" either does not exist or you do not have permission to use it. (2760) (SQLExecDirectW)'))

@prh-t
Copy link

prh-t commented Feb 13, 2021

Getting the same error, wondering if you've had any luck resolving this issue?

@anas-fladdra
Copy link

anas-fladdra commented Sep 14, 2022

Getting the same error, wondering if you've had any luck resolving this issue? Pccch

@RomanShyshcenko
Copy link

same

1 similar comment
@uttamvelani11
Copy link

same

@safu-van
Copy link

have anyone get the solution

@sabghat90
Copy link

Open pgAdmin Windows software, then navigate to the server you created, open databases, and then go to Login/Group Roles, select your login role, like myuser which you have created, open properties, and then go to Privileges, make superuser, and then apply the python manage.py migrate command.

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

7 participants