michiya / django-pyodbc-azure

Django backend for Microsoft SQL Server and Azure SQL Database using pyodbc
https://pypi.python.org/pypi/django-pyodbc-azure
BSD 3-Clause "New" or "Revised" License
321 stars 140 forks source link

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 4 years ago

harshacheemakurt commented 4 years ago

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 commented 3 years ago

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

anas-fladdra commented 2 years ago

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

RomanShyshcenko commented 11 months ago

same

uttamvelani11 commented 7 months ago

same

safu-van commented 4 months ago

have anyone get the solution

sabghat90 commented 1 month ago

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